FormatValidatorPass   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 19
ccs 0
cts 10
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 13 3
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
        $constraintFactoryDefinition = $container->getDefinition('swagger.json_schema.constraints.factory');
17
        $formatConstraintDefinition = $container->getDefinition('swagger.json_schema.constraints.format');
18
19
        $services = $container->findTaggedServiceIds('swagger.format_validator');
20
        foreach ($services as $serviceId => $tags) {
21
            foreach ($tags as $attributes) {
22
                $formatConstraintDefinition->addMethodCall('addFormatValidator', [$attributes['format'], new Reference($serviceId)]);
23
                $constraintFactoryDefinition->addMethodCall('setFormatValidator', [$attributes['format'], new Reference($serviceId)]);
24
            }
25
        }
26
    }
27
}
28