Conditions | 6 |
Paths | 6 |
Total Lines | 21 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 42 |
Changes | 0 |
1 | <?php declare(strict_types=1); |
||
18 | public function provision( |
||
19 | Injector $injector, |
||
20 | ConfigProviderInterface $configProvider, |
||
21 | ServiceDefinitionInterface $serviceDefinition |
||
22 | ): void { |
||
23 | $serviceClass = $serviceDefinition->getServiceClass(); |
||
24 | $settings = $serviceDefinition->getSettings(); |
||
25 | |||
26 | $injector->define($serviceClass, [':settings' => $settings]); |
||
27 | |||
28 | // there will only be one instance of the service when the "share" setting is true (default) |
||
29 | if (!isset($settings['_share']) || true === $settings['_share']) { |
||
30 | $injector->share($serviceClass); |
||
31 | } |
||
32 | |||
33 | if (isset($settings['_alias'])) { |
||
34 | $alias = $settings['_alias']; |
||
35 | if (!is_string($alias) && !class_exists($alias)) { |
||
36 | throw new RuntimeException('Alias must be an existing fully qualified class or interface name.'); |
||
37 | } |
||
38 | $injector->alias($alias, $serviceClass); |
||
39 | } |
||
42 |