Completed
Push — master ( 8b8539...de5cc9 )
by Tristan
13:08 queued 08:55
created

FormatValidatorPass::process()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 0
cts 10
cp 0
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 6
nc 3
nop 1
crap 12
1
<?php
2
3
namespace Nicofuma\SwaggerBundle\DependencyInjection\Compiler;
4
5
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
use Symfony\Component\DependencyInjection\Reference;
8
9
class FormatValidatorPass implements CompilerPassInterface
10
{
11
    /**
12
     * {@inheritdoc}
13
     */
14
    public function process(ContainerBuilder $container)
15
    {
16
        $formatConstraintDefinition = $container->getDefinition('swagger.json_schema.constraints.format');
17
18
        $services = $container->findTaggedServiceIds('swagger.format_validator');
19
        foreach ($services as $serviceId => $tags) {
20
            foreach ($tags as $attributes) {
21
                $formatConstraintDefinition->addMethodCall('addFormatValidator', [$attributes['format'], new Reference($serviceId)]);
22
            }
23
        }
24
    }
25
}
26