| Conditions | 2 |
| Paths | 1 |
| Total Lines | 28 |
| Code Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 6 |
| Changes | 0 | ||
| 1 | <?php declare(strict_types=1); |
||
| 19 | public function provision( |
||
| 20 | Injector $injector, |
||
| 21 | ConfigProviderInterface $configProvider, |
||
| 22 | ServiceDefinitionInterface $serviceDefinition |
||
| 23 | ): void { |
||
| 24 | $serviceClass = $serviceDefinition->getServiceClass(); |
||
| 25 | $adapterConfigs = (array)$configProvider->get('databases.stream_stores', []); |
||
| 26 | $factory = function ( |
||
| 27 | StorageAdapterMap $storageAdapterMap |
||
| 28 | ) use ( |
||
| 29 | $injector, |
||
| 30 | $serviceClass, |
||
| 31 | $adapterConfigs |
||
| 32 | ): object { |
||
| 33 | $adapters = []; |
||
| 34 | foreach ($adapterConfigs as $adapterKey => $adapterConfigs) { |
||
| 35 | Assertion::keyNotExists($adapters, $adapterKey, "Stream adapter '$adapterKey' is already defined."); |
||
| 36 | $adapters[$adapterKey] = $injector->make( |
||
| 37 | $adapterConfigs['class'], |
||
| 38 | [':storageAdapter' => $storageAdapterMap->get($adapterConfigs['storage_adapter'])] |
||
| 39 | ); |
||
| 40 | } |
||
| 41 | return new $serviceClass($adapters); |
||
| 42 | }; |
||
| 43 | |||
| 44 | $injector |
||
| 45 | ->share($serviceClass) |
||
| 46 | ->delegate($serviceClass, $factory); |
||
| 47 | } |
||
| 49 |