Conditions | 4 |
Paths | 4 |
Total Lines | 23 |
Lines | 0 |
Ratio | 0 % |
Tests | 12 |
CRAP Score | 4 |
Changes | 0 |
1 | <?php |
||
23 | 11 | protected function getConstructorParams(string $class): array |
|
24 | { |
||
25 | 11 | $params = []; |
|
26 | |||
27 | try { |
||
28 | 11 | $reflection = new ReflectionClass($class); |
|
29 | 2 | } catch (ReflectionException $e) { |
|
30 | 2 | throw ClassNotFoundException::create($class); |
|
31 | } |
||
32 | |||
33 | 9 | $constructor = $reflection->getConstructor(); |
|
34 | |||
35 | 9 | if ($constructor === null) { |
|
36 | 8 | return $params; |
|
37 | } |
||
38 | |||
39 | 4 | foreach ($constructor->getParameters() AS $param) { |
|
40 | 4 | $dependencyId = $param->getClass()->name; |
|
41 | 4 | $params[] = $this->getContainer()->get($dependencyId); |
|
42 | } |
||
43 | |||
44 | 3 | return $params; |
|
45 | } |
||
46 | } |
||
47 |