| Conditions | 4 |
| Paths | 5 |
| Total Lines | 21 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 12 | public function createInstance(Container $container, $serviceName, array $serviceConfig) |
||
| 13 | { |
||
| 14 | $className = $serviceConfig['class']; |
||
| 15 | |||
| 16 | if (! class_exists($className)) { |
||
| 17 | throw new UnbuildableServiceException(sprintf("Class '%s' not found.", $className)); |
||
| 18 | } |
||
| 19 | |||
| 20 | $class = new \ReflectionClass($className); |
||
| 21 | $activationArgs = isset($serviceConfig['arguments']) ? |
||
| 22 | ParamsResolver::resolveParams($container, $serviceConfig['arguments']) : array(); |
||
| 23 | |||
| 24 | if (! empty($activationArgs)) { |
||
| 25 | $instance = $class->newInstanceArgs($activationArgs); |
||
| 26 | } |
||
| 27 | else { |
||
| 28 | $instance = $class->newInstance(); |
||
| 29 | } |
||
| 30 | |||
| 31 | return $instance; |
||
| 32 | } |
||
| 33 | } |
||
| 34 |