buildDefaultConfig()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php declare(strict_types = 1);
2
3
namespace TomCizek\SymfonyProoph\AsynchronousMessages\Configurators;
4
5
use Symfony\Component\DependencyInjection\Definition;
6
use Symfony\Component\DependencyInjection\Reference;
7
use TomCizek\SymfonyProoph\AsynchronousMessages\AsynchronousMessageProducer;
8
use TomCizek\SymfonyProoph\AsynchronousMessages\Factories\AbstractAsynchronousMessageProducerFactory;
9
use TomCizek\SymfonyProoph\Common\DefaultConfigurator;
10
11
abstract class AbstractAsynchronousProducerConfigurator extends DefaultConfigurator
12
{
13
	abstract public function getProducerFactoryClass(): string;
14
15 18
	public function buildDefaultConfig(): array
16
	{
17 18
		return [];
18
	}
19
20 16
	public function configureWithConfig(array $config): void
21
	{
22 16
		if (empty($config[AbstractAsynchronousMessageProducerFactory::KEY_BRIDGE])) {
23 16
			return;
24
		}
25
26 5
		$interopContainerServiceId = $this->getInteropContainerServiceId();
27
28 5
		$asynchronousProducerDefinition = new Definition(AsynchronousMessageProducer::class);
29
		$asynchronousProducerDefinition
30 5
			->setFactory($this->getProducerFactoryClass() . '::' . $this->getConfigKey())
31 5
			->addArgument(
32 5
				new Reference($interopContainerServiceId)
33
			);
34
35 5
		$asynchronousProducerName = 'prooph.asynchronous_messaging.' . $this->getConfigKey();
36
37 5
		$this->containerBuilder->setDefinition($asynchronousProducerName, $asynchronousProducerDefinition);
38 5
	}
39
}
40