| Conditions | 4 |
| Paths | 5 |
| Total Lines | 15 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 16 | protected function fromClass(string $name) { |
||
| 17 | if (class_exists($name, true) === false) |
||
| 18 | return null; |
||
| 19 | |||
| 20 | if (method_exists($name, '__construct') === false) |
||
| 21 | $value = new $name; |
||
| 22 | else { |
||
| 23 | $method = new \ReflectionMethod($name, '__construct'); |
||
| 24 | $value = new $name(...$this->autowire($method)); |
||
|
|
|||
| 25 | } |
||
| 26 | |||
| 27 | if ($value instanceof Injectable) |
||
| 28 | return new Bean($name, $value); |
||
| 29 | |||
| 30 | throw new ClassNotInjectable($name); |
||
| 31 | } |
||
| 32 | } |