CompositeConfigurator   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 0
loc 36
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
createConfigurators() 0 1 ?
getConfigKey() 0 1 ?
A buildDefaultConfig() 0 9 2
A configureWithConfig() 0 7 2
1
<?php declare(strict_types = 1);
2
3
namespace TomCizek\SymfonyProoph\Common;
4
5
use Symfony\Component\DependencyInjection\ContainerBuilder;
6
7
abstract class CompositeConfigurator extends DefaultConfigurator
8
{
9
	/** @var Configurator[] */
10
	public $configurators = [];
11
12 19
	public function __construct(ContainerBuilder $containerBuilder)
13
	{
14 19
		parent::__construct($containerBuilder);
15 19
		$this->configurators = $this->createConfigurators();
16 19
	}
17
18
	/**
19
	 * @return Configurator[]
20
	 */
21
	abstract protected function createConfigurators(): array;
22
23
	abstract public function getConfigKey(): ?string;
24
25 18
	public function buildDefaultConfig(): array
26
	{
27 18
		$config = [];
28 18
		foreach ($this->configurators as $configurator) {
29 18
			$config[$configurator->getConfigKey()] = $configurator->buildDefaultConfig();
30
		}
31
32 18
		return $config;
33
	}
34
35 18
	public function configureWithConfig(array $config): void
36
	{
37 18
		foreach ($this->configurators as $configurator) {
38 18
			$serviceConfig = $config[$configurator->getConfigKey()];
39 18
			$configurator->configureWithConfig($serviceConfig);
40
		}
41 16
	}
42
}
43