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