| Conditions | 8 |
| Paths | 10 |
| Total Lines | 31 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 31 | #[Override] |
||
| 32 | public function __invoke(string $varName, array $query, InjectorInterface $injector) |
||
| 33 | { |
||
| 34 | $type = $this->parameter->getType(); |
||
| 35 | if ($type instanceof ReflectionNamedType && ! $type->isBuiltin()) { |
||
| 36 | $inputClass = $type->getName(); |
||
| 37 | assert(class_exists($inputClass)); |
||
| 38 | |||
| 39 | return $this->inputQuery->newInstance($inputClass, $query); |
||
| 40 | } |
||
| 41 | |||
| 42 | // For built-in types, handle missing values explicitly |
||
| 43 | if (array_key_exists($varName, $query)) { |
||
| 44 | return $query[$varName]; |
||
| 45 | } |
||
| 46 | |||
| 47 | $type = $this->parameter->getType(); |
||
| 48 | $isRequired = true; |
||
| 49 | if ($type instanceof ReflectionNamedType && $type->allowsNull()) { |
||
| 50 | $isRequired = false; |
||
| 51 | } |
||
| 52 | |||
| 53 | if ($this->parameter->isDefaultValueAvailable()) { |
||
| 54 | $isRequired = false; |
||
| 55 | } |
||
| 56 | |||
| 57 | if ($isRequired) { |
||
| 58 | throw new InvalidArgumentException("Missing required parameter: {$varName}"); |
||
| 59 | } |
||
| 60 | |||
| 61 | return null; |
||
| 62 | } |
||
| 64 |