| Conditions | 3 |
| Paths | 1 |
| Total Lines | 26 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 12 |
| Changes | 1 | ||
| Bugs | 0 | Features | 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' => isset($serviceConfig['connector']) |
||
| 33 | ? $connectorMap->get($serviceConfig['connector']) |
||
| 34 | : null, |
||
| 35 | ':settings' => $serviceConfig['settings'] ?? [] |
||
| 36 | ] |
||
| 37 | )->make($serviceClass); |
||
| 38 | } |
||
| 39 | return new PaymentServiceMap($services); |
||
| 40 | }; |
||
| 41 | |||
| 42 | $injector |
||
| 43 | ->share(PaymentServiceMap::class) |
||
| 44 | ->delegate(PaymentServiceMap::class, $factory); |
||
| 45 | } |
||
| 47 |