Conditions | 3 |
Paths | 1 |
Total Lines | 25 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 12 |
Changes | 0 |
1 | <?php declare(strict_types=1); |
||
19 | public function provision( |
||
20 | Injector $injector, |
||
21 | ConfigProviderInterface $configProvider, |
||
22 | ServiceDefinitionInterface $serviceDefinition |
||
23 | ): void { |
||
24 | $serviceConfigs = $configProvider->get('payments.services', []); |
||
25 | $factory = function (ConnectorMap $connectorMap) use ($injector, $serviceConfigs): PaymentServiceMap { |
||
26 | $services = []; |
||
27 | foreach ($serviceConfigs as $serviceName => $serviceConfig) { |
||
28 | $serviceClass = $serviceConfig['class']; |
||
29 | $services[$serviceName] = $injector->define( |
||
30 | $serviceClass, |
||
31 | [ |
||
32 | ':connector' => |
||
33 | $serviceConfig['connector'] ? $connectorMap->get($serviceConfig['connector']) : null, |
||
34 | ':settings' => $serviceConfig['settings'] ?? [] |
||
35 | ] |
||
36 | )->make($serviceClass); |
||
37 | } |
||
38 | return new PaymentServiceMap($services); |
||
39 | }; |
||
40 | |||
41 | $injector |
||
42 | ->share(PaymentServiceMap::class) |
||
43 | ->delegate(PaymentServiceMap::class, $factory); |
||
44 | } |
||
46 |