GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

CompileHasherServicesPass::process()   B
last analyzed

Complexity

Conditions 6
Paths 6

Size

Total Lines 36
Code Lines 21

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 21
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 36
ccs 21
cts 21
cp 1
rs 8.439
c 0
b 0
f 0
cc 6
eloc 21
nc 6
nop 1
crap 6
1
<?php
2
3
namespace Ma27\ApiKeyAuthenticationBundle\DependencyInjection\Compiler;
4
5
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
8
/**
9
 * Compiler pass which gathers hasher services and keeps them inside a private parameter.
10
 * The configuration can declare which hash service to use and this one will be fetched from the parameter.
11
 *
12
 * @internal
13
 */
14
class CompileHasherServicesPass implements CompilerPassInterface
15
{
16
    /**
17
     * {@inheritdoc}
18
     *
19
     * @throws \LogicException If multiple tags at one service exist.
20
     * @throws \LogicException If no appropriate tag is given.
21
     * @throws \LogicException If no alias is given.
22
     */
23 12
    public function process(ContainerBuilder $container)
24
    {
25 12
        if (!$container->hasParameter('ma27_api_key_authentication.password_hashing_service')) {
26 1
            return;
27
        }
28
29 11
        $alias = $container->getParameter('ma27_api_key_authentication.password_hashing_service');
30 11
        foreach ($container->findTaggedServiceIds('ma27_api_key_authentication.password_hasher') as $id => $tags) {
31 11
            if (count($tags) > 1) {
32 1
                throw new \LogicException(sprintf(
33 1
                    'Service "%s" can have the tag "%s" only one time!',
34 1
                    $id,
35 1
                    'ma27_api_key_authentication.password_hasher'
36
                ));
37
            }
38
39 10
            if (!array_key_exists('alias', $tags[0])) {
40 1
                throw new \LogicException(sprintf(
41 1
                    'The tag "%s" on service "%s" needs an `alias` property!',
42 1
                    'ma27_api_key_authentication.password_hasher',
43 1
                    $id
44
                ));
45
            }
46
47 9
            if ($tags[0]['alias'] === $alias) {
48 8
                $container->setAlias('ma27_api_key_authentication.password.strategy', $id);
49
50 9
                return;
51
            }
52
        }
53
54 1
        throw new \LogicException(sprintf(
55 1
            'No service found for hashing alias "%s"!',
56 1
            $alias
57
        ));
58
    }
59
}
60