@@ -37,80 +37,58 @@ final class Route implements RouteDescriptorInterface
3737{
3838
3939 /**
40- * A route name
41- *
4240 * @var string
4341 */
4442 private $ name ;
4543
4644 /**
47- * A route host
48- *
4945 * @var null|string
5046 */
5147 private $ host ;
5248
5349 /**
54- * A route path
55- *
5650 * @var string
5751 */
5852 private $ path ;
5953
6054 /**
61- * A route methods
62- *
6355 * @var string[]
6456 */
6557 private $ methods ;
6658
6759 /**
68- * A route middlewares
69- *
7060 * @var string[]
7161 */
7262 private $ middlewares ;
7363
7464 /**
75- * A route attributes
76- *
7765 * @var array
7866 */
7967 private $ attributes ;
8068
8169 /**
82- * A route summary
83- *
8470 * @var string
8571 */
8672 private $ summary ;
8773
8874 /**
89- * A route description
90- *
9175 * @var string
9276 */
9377 private $ description ;
9478
9579 /**
96- * A route tags
97- *
9880 * @var string[]
9981 */
10082 private $ tags ;
10183
10284 /**
103- * A route priority
104- *
10585 * @var int
10686 */
10787 private $ priority ;
10888
10989 /**
11090 * Constructor of the annotation
111- *
11291 * @param array $params
113- *
11492 * @throws InvalidDescriptorArgumentException
11593 */
11694 public function __construct (array $ params )
@@ -207,71 +185,39 @@ public function getPriority() : int
207185 return $ this ->priority ;
208186 }
209187
210- /**
211- * @param array $params
212- *
213- * @return string
214- *
215- * @throws InvalidDescriptorArgumentException
216- */
217188 private function extractNameFromParams (array $ params ) : string
218189 {
219190 $ name = $ params ['name ' ] ?? '' ;
220-
221191 if ('' === $ name || !is_string ($ name )) {
222192 throw new InvalidDescriptorArgumentException ('@Route.name must contain a non-empty string. ' );
223193 }
224194
225195 return $ name ;
226196 }
227197
228- /**
229- * @param array $params
230- *
231- * @return null|string
232- *
233- * @throws InvalidDescriptorArgumentException
234- */
235198 private function extractHostFromParams (array $ params ) : ?string
236199 {
237200 $ host = $ params ['host ' ] ?? null ;
238-
239201 if (isset ($ host ) && ('' === $ host || !is_string ($ host ))) {
240202 throw new InvalidDescriptorArgumentException ('@Route.host must contain a non-empty string. ' );
241203 }
242204
243205 return $ host ;
244206 }
245207
246- /**
247- * @param array $params
248- *
249- * @return string
250- *
251- * @throws InvalidDescriptorArgumentException
252- */
253208 private function extractPathFromParams (array $ params ) : string
254209 {
255210 $ path = $ params ['path ' ] ?? '' ;
256-
257211 if ('' === $ path || !is_string ($ path )) {
258212 throw new InvalidDescriptorArgumentException ('@Route.path must contain a non-empty string. ' );
259213 }
260214
261215 return $ path ;
262216 }
263217
264- /**
265- * @param array $params
266- *
267- * @return string[]
268- *
269- * @throws InvalidDescriptorArgumentException
270- */
271218 private function extractMethodsFromParams (array $ params ) : array
272219 {
273220 $ methods = $ params ['methods ' ] ?? [];
274-
275221 if ([] === $ methods || !is_array ($ methods )) {
276222 throw new InvalidDescriptorArgumentException ('@Route.methods must contain a non-empty array. ' );
277223 }
@@ -285,17 +231,9 @@ private function extractMethodsFromParams(array $params) : array
285231 return $ methods ;
286232 }
287233
288- /**
289- * @param array $params
290- *
291- * @return string[]
292- *
293- * @throws InvalidDescriptorArgumentException
294- */
295234 private function extractMiddlewaresFromParams (array $ params ) : array
296235 {
297236 $ middlewares = $ params ['middlewares ' ] ?? [];
298-
299237 if (!is_array ($ middlewares )) {
300238 throw new InvalidDescriptorArgumentException ('@Route.middlewares must contain an array. ' );
301239 }
@@ -311,71 +249,39 @@ private function extractMiddlewaresFromParams(array $params) : array
311249 return $ middlewares ;
312250 }
313251
314- /**
315- * @param array $params
316- *
317- * @return array
318- *
319- * @throws InvalidDescriptorArgumentException
320- */
321252 private function extractAttributesFromParams (array $ params ) : array
322253 {
323254 $ attributes = $ params ['attributes ' ] ?? [];
324-
325255 if (!is_array ($ attributes )) {
326256 throw new InvalidDescriptorArgumentException ('@Route.attributes must contain an array. ' );
327257 }
328258
329259 return $ attributes ;
330260 }
331261
332- /**
333- * @param array $params
334- *
335- * @return string
336- *
337- * @throws InvalidDescriptorArgumentException
338- */
339262 private function extractSummaryFromParams (array $ params ) : string
340263 {
341264 $ summary = $ params ['summary ' ] ?? '' ;
342-
343265 if (!is_string ($ summary )) {
344266 throw new InvalidDescriptorArgumentException ('@Route.summary must contain a string. ' );
345267 }
346268
347269 return $ summary ;
348270 }
349271
350- /**
351- * @param array $params
352- *
353- * @return string
354- *
355- * @throws InvalidDescriptorArgumentException
356- */
357272 private function extractDescriptionFromParams (array $ params ) : string
358273 {
359274 $ description = $ params ['description ' ] ?? '' ;
360-
361275 if (!is_string ($ description )) {
362276 throw new InvalidDescriptorArgumentException ('@Route.description must contain a string. ' );
363277 }
364278
365279 return $ description ;
366280 }
367281
368- /**
369- * @param array $params
370- *
371- * @return string[]
372- *
373- * @throws InvalidDescriptorArgumentException
374- */
375282 private function extractTagsFromParams (array $ params ) : array
376283 {
377284 $ tags = $ params ['tags ' ] ?? [];
378-
379285 if (!is_array ($ tags )) {
380286 throw new InvalidDescriptorArgumentException ('@Route.tags must contain an array. ' );
381287 }
@@ -389,17 +295,9 @@ private function extractTagsFromParams(array $params) : array
389295 return $ tags ;
390296 }
391297
392- /**
393- * @param array $params
394- *
395- * @return int
396- *
397- * @throws InvalidDescriptorArgumentException
398- */
399298 private function extractPriorityFromParams (array $ params ) : int
400299 {
401300 $ priority = $ params ['priority ' ] ?? 0 ;
402-
403301 if (!is_int ($ priority )) {
404302 throw new InvalidDescriptorArgumentException ('@Route.priority must contain an integer. ' );
405303 }
0 commit comments