| Total Complexity | 4 |
| Total Lines | 30 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 12 | final readonly class NamedParameter implements NamedParameterInterface |
||
|
|
|||
| 13 | { |
||
| 14 | public function __construct( |
||
| 15 | private NamedParamMetasInterface $paramMetas, |
||
| 16 | private InjectorInterface $injector, |
||
| 17 | ) { |
||
| 18 | } |
||
| 19 | |||
| 20 | /** |
||
| 21 | 107 | * {@inheritDoc} |
|
| 22 | * |
||
| 23 | 107 | * @throws ParameterException Thrown when the query parameter is invalid. |
|
| 24 | 107 | */ |
|
| 25 | 107 | #[Override] |
|
| 26 | public function getParameters(callable $callable, array $query): array |
||
| 27 | { |
||
| 28 | $metas = ($this->paramMetas)($callable); |
||
| 29 | $parameters = []; |
||
| 30 | 75 | foreach ($metas as $varName => $param) { |
|
| 31 | |||
| 32 | 75 | /** @psalm-suppress MixedAssignment */ |
|
| 33 | 75 | try { |
|
| 34 | 75 | $parameters[$varName] = $param($varName, $query, $this->injector); |
|
| 35 | } catch (InvalidArgumentException $e) { |
||
| 36 | 68 | // handle missing query parameter in Ray.InputQuery |
|
| 37 | throw new ParameterException($varName, $e->getCode(), $e); |
||
| 38 | } |
||
| 39 | 68 | } |
|
| 40 | |||
| 41 | return $parameters; |
||
| 42 | } |
||
| 44 |