ResponseFactory::createReference()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 1
crap 1
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