Completed
Push — develop ( 64a224...17d645 )
by Florent
03:11
created

CheckerCompilerPass::process()   B

Complexity

Conditions 6
Paths 10

Size

Total Lines 23
Code Lines 14

Duplication

Lines 12
Ratio 52.17 %

Importance

Changes 2
Bugs 1 Features 1
Metric Value
c 2
b 1
f 1
dl 12
loc 23
rs 8.5906
cc 6
eloc 14
nc 10
nop 1
1
<?php
2
3
/*
4
 * The MIT License (MIT)
5
 *
6
 * Copyright (c) 2014-2016 Spomky-Labs
7
 *
8
 * This software may be modified and distributed under the terms
9
 * of the MIT license.  See the LICENSE file for details.
10
 */
11
12
namespace SpomkyLabs\JoseBundle\DependencyInjection\Compiler;
13
14
use Assert\Assertion;
15
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
16
use Symfony\Component\DependencyInjection\ContainerBuilder;
17
use Symfony\Component\DependencyInjection\Reference;
18
19
final class CheckerCompilerPass implements CompilerPassInterface
20
{
21
    public function process(ContainerBuilder $container)
22
    {
23
        if (!$container->hasDefinition('jose.checker_manager')) {
24
            return;
25
        }
26
27
        $definition = $container->getDefinition('jose.checker_manager');
28
29
        $taggedClaimCheckerServices = $container->findTaggedServiceIds('jose.checker.claim');
30
        $taggedHeaderCheckerServices = $container->findTaggedServiceIds('jose.checker.header');
31 View Code Duplication
        foreach ($taggedClaimCheckerServices as $id => $tags) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
32
            foreach ($tags as $attributes) {
33
                Assertion::keyExists($attributes, 'alias', sprintf("The claim checker '%s' does not have any 'alias' attribute.", $id));
34
                $definition->addMethodCall('addClaimChecker', [new Reference($id), $attributes['alias']]);
35
            }
36
        }
37 View Code Duplication
        foreach ($taggedHeaderCheckerServices as $id => $tags) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
38
            foreach ($tags as $attributes) {
39
                Assertion::keyExists($attributes, 'alias', sprintf("The header checker '%s' does not have any 'alias' attribute.", $id));
40
                $definition->addMethodCall('addHeaderChecker', [new Reference($id), $attributes['alias']]);
41
            }
42
        }
43
    }
44
}
45