Total Complexity | 8 |
Total Lines | 55 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
17 | final class InputAttributeIterator |
||
18 | { |
||
19 | /** |
||
20 | * Yield parameters that have Input attribute |
||
21 | * |
||
22 | * @param ReflectionMethod $method |
||
23 | * |
||
24 | * @return Generator<string, ReflectionParameter> |
||
25 | */ |
||
26 | public function __invoke(ReflectionMethod $method): Generator |
||
27 | { |
||
28 | foreach ($method->getParameters() as $parameter) { |
||
29 | $attributes = $parameter->getAttributes(Input::class); |
||
30 | if (count($attributes) <= 0) { |
||
31 | continue; |
||
32 | } |
||
33 | |||
34 | yield $parameter->getName() => $parameter; |
||
35 | } |
||
36 | } |
||
37 | |||
38 | /** |
||
39 | * Get Input attribute instance from parameter |
||
40 | * |
||
41 | * @param ReflectionParameter $parameter |
||
42 | * |
||
43 | * @return Input|null |
||
44 | */ |
||
45 | public function getInputAttribute(ReflectionParameter $parameter): Input|null |
||
53 | } |
||
54 | |||
55 | /** |
||
56 | * Check if method has any Input attribute parameters |
||
57 | * |
||
58 | * @param ReflectionMethod $method |
||
59 | * |
||
60 | * @return bool |
||
61 | */ |
||
62 | public function hasInputParameters(ReflectionMethod $method): bool |
||
72 | } |
||
73 | } |
||
74 |