Completed
Push — master ( 8cd050...5f288c )
by Andreas
22:58
created

translatorPass   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 8
c 0
b 0
f 0
dl 0
loc 16
ccs 10
cts 10
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A get_prefix() 0 5 1
A process() 0 6 1
1
<?php
2
namespace midcom\bundle\dependencyInjection;
3
4
use Symfony\Component\DependencyInjection\ContainerBuilder;
5
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
6
7
class translatorPass implements CompilerPassInterface
8
{
9 1
    public function process(ContainerBuilder $container)
10
    {
11 1
        $container->getDefinition('translator')
12 1
            ->addArgument([
13 1
                $this->get_prefix($container, 'validator.builder'),
14 1
                $this->get_prefix($container, 'form.factory')
15
            ]);
16 1
    }
17
18 1
    private static function get_prefix(ContainerBuilder $container, string $id) : string
19
    {
20 1
        $service = $container->getDefinition($id);
21 1
        $rc = new \ReflectionClass($service->getClass());
22 1
        return dirname($rc->getFileName()) . '/Resources/translations/validators.';
23
    }
24
}