ResponseFactory   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 44.44%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 13
c 1
b 0
f 0
dl 0
loc 29
ccs 4
cts 9
cp 0.4444
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A createReference() 0 3 1
A createId() 0 3 1
A register() 0 6 2
1
<?php
2
3
namespace Lamoda\Metric\MetricBundle\DependencyInjection\DefinitionFactory;
4
5
use Symfony\Component\DependencyInjection\ContainerBuilder;
6
use Symfony\Component\DependencyInjection\Reference;
7
8
/**
9
 * @internal
10
 */
11
final class ResponseFactory
12
{
13
    public const TAG = 'lamoda_metrics.response_factory';
14
    public const ALIAS_ATTRIBUTE = 'alias';
15
16
    public const TYPES = [
17
        self::FACTORY_TYPE_SERVICE,
18
    ];
19
20
    private const FACTORY_TYPE_SERVICE = 'service';
21
22
    private const ID_PREFIX = 'lamoda_metrics.response_factory.';
23
24 4
    public static function createId(string $name): string
25
    {
26 4
        return self::ID_PREFIX . $name;
27
    }
28
29 4
    public static function createReference(string $name): Reference
30
    {
31 4
        return new Reference(self::createId($name));
32
    }
33
34
    public static function register(ContainerBuilder $container, string $name, array $config): void
35
    {
36
        switch ($config['type']) {
37
            case self::FACTORY_TYPE_SERVICE:
38
                $container->setAlias(self::createId($name), $config['id']);
39
                break;
40
        }
41
    }
42
}
43