Completed
Pull Request — master (#4)
by ANTHONIUS
04:04
created

ValidationPass::process()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 16
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 8
nc 3
nop 1
dl 0
loc 16
ccs 9
cts 9
cp 1
crap 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
4
namespace Doyo\UserBundle\DependencyInjection\Compiler;
5
6
7
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
8
use Symfony\Component\DependencyInjection\ContainerBuilder;
9
10
class ValidationPass implements CompilerPassInterface
11
{
12
    /**
13
     * {@inheritdoc}
14
     */
15 3
    public function process(ContainerBuilder $container)
16
    {
17 3
        if (!$container->hasParameter('doyo_user.storage')) {
18 1
            return;
19
        }
20
21 2
        $storage = $container->getParameter('doyo_user.storage');
22
23 2
        if ('custom' === $storage) {
24 1
            return;
25
        }
26
27 1
        $validationFile = __DIR__.'/../../Resources/config/storage-validation/'.$storage.'.yaml';
28
29 1
        $container->getDefinition('validator.builder')
30 1
            ->addMethodCall('addYamlMapping', array($validationFile));
31
    }
32
}