| Total Complexity | 4 |
| Total Lines | 33 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 3 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 11 | class RedisExtension extends ConfigurableExtension |
||
| 12 | { |
||
| 13 | /** |
||
| 14 | * loadInternal. |
||
| 15 | * |
||
| 16 | 7 | * @param array[] $configs |
|
| 17 | * @param ContainerBuilder $container |
||
| 18 | 7 | */ |
|
| 19 | 7 | protected function loadInternal(array $configs, ContainerBuilder $container): void |
|
| 20 | { |
||
| 21 | 7 | $factoryReference = new Reference(Redis\FactoryInterface::class); |
|
| 22 | 7 | $container->setDefinition($factoryReference, new Definition(Redis\Factory::class)); |
|
| 23 | 7 | ||
| 24 | 7 | foreach ($configs['clients'] as $name => $arguments) { |
|
| 25 | 7 | $definition = new Definition(Redis\Client::class); |
|
| 26 | $definition->setFactory([$factoryReference, 'create']); |
||
| 27 | 7 | $definition->setArguments([$arguments['$parameters'], $arguments['$options']]); |
|
| 28 | $definition->setPublic(true); |
||
| 29 | 7 | ||
| 30 | 7 | $container->setDefinition(sprintf('%s.%s', $this->getAlias(), $name), $definition); |
|
| 31 | |||
| 32 | if (false === $container->hasDefinition(Redis\ClientInterface::class)) { |
||
| 33 | 7 | $container->setDefinition(Redis\ClientInterface::class, $definition); |
|
| 34 | } |
||
| 35 | } |
||
| 36 | } |
||
| 37 | |||
| 38 | 8 | /** |
|
| 39 | * {@inheritdoc} |
||
| 40 | 8 | */ |
|
| 41 | public function getAlias(): string |
||
| 44 | } |
||
| 45 | } |
||
| 46 |