AbstractAsynchronousProducerConfigurator   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 4
dl 0
loc 29
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
getProducerFactoryClass() 0 1 ?
A buildDefaultConfig() 0 4 1
A configureWithConfig() 0 19 2
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