AbstractInteropExtension::process()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php declare(strict_types = 1);
2
3
namespace TomCizek\SymfonyInteropContainer;
4
5
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
use Symfony\Component\DependencyInjection\Extension\Extension;
8
9
abstract class AbstractInteropExtension extends Extension implements CompilerPassInterface
10
{
11
	/** @var ConfigArrayBuilder */
12
	protected $configBuilder;
13
14 8
	public function load(array $configs, ContainerBuilder $containerBuilder)
15
	{
16 8
		$this->configBuilder = ConfigArrayBuilder::withConfigsOnKey($configs, $this->getAlias());
0 ignored issues
show
Documentation Bug introduced by
It seems like \TomCizek\SymfonyInterop...igs, $this->getAlias()) of type object<self> is incompatible with the declared type object<TomCizek\SymfonyI...ner\ConfigArrayBuilder> of property $configBuilder.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
17 8
	}
18
19 8
	public function process(ContainerBuilder $containerBuilder)
20
	{
21 8
		$this->setupConfigInInteropContainer($containerBuilder);
22 8
	}
23
24
	/**
25
	 * @param ContainerBuilder $containerBuilder
26
	 *
27
	 * @throws \Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException
28
	 * @throws \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException
29
	 */
30 8
	protected function setupConfigInInteropContainer(ContainerBuilder $containerBuilder): void
31
	{
32
		/** @var SymfonyInteropContainer $containerWrapper */
33 8
		$interopContainerDefinition = $containerBuilder->getDefinition('interop_container');
34 8
		$interopContainerDefinition->addMethodCall(
35 8
			'mergeOverConfigOnKey',
36
			[
37 8
				$this->configBuilder->getKey(),
38 8
				$this->configBuilder->build(),
39
			]
40
		);
41 8
	}
42
}
43