| Conditions | 5 |
| Paths | 4 |
| Total Lines | 22 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 13 |
| CRAP Score | 5 |
| Changes | 0 | ||
| 1 | <?php |
||
| 22 | 4 | public function resolve(callable $callable): array |
|
| 23 | { |
||
| 24 | 4 | $arguments = []; |
|
| 25 | |||
| 26 | 4 | $closure = \Closure::fromCallable($callable); |
|
| 27 | 4 | $reflection = new \ReflectionMethod($closure, '__invoke'); |
|
| 28 | 4 | $parameters = $reflection->getParameters(); |
|
| 29 | |||
| 30 | 4 | foreach ($parameters as $parameter) { |
|
| 31 | 4 | if (!$class = $parameter->getClass()) { |
|
| 32 | 3 | continue; |
|
| 33 | } |
||
| 34 | |||
| 35 | 4 | $expected = $class->getName(); |
|
| 36 | 4 | $instance = $this->resolveArgument($class); |
|
| 37 | |||
| 38 | 4 | if (\is_object($instance) && $instance instanceof $expected) { |
|
| 39 | 4 | $arguments[$parameter->getPosition()] = $instance; |
|
| 40 | } |
||
| 41 | } |
||
| 42 | |||
| 43 | 4 | return $arguments; |
|
| 44 | } |
||
| 53 |