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.
Completed
Push — master ( 8fd0d0...68d83c )
by Maximilian
03:22
created

CompileHasherServicesPass   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
c 1
b 0
f 0
lcom 0
cbo 1
dl 0
loc 45
ccs 22
cts 22
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B process() 0 35 6
1
<?php
2
3
/*
4
 * This file is part of the Sententiaregum project.
5
 *
6
 * (c) Maximilian Bosch <[email protected]>
7
 * (c) Ben Bieler <[email protected]>
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
namespace Ma27\ApiKeyAuthenticationBundle\DependencyInjection\Compiler;
14
15
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
16
use Symfony\Component\DependencyInjection\ContainerBuilder;
17
18
/**
19
 * Compiler pass which gathers hasher services and keeps them inside a private parameter.
20
 * The configuration can declare which hash service to use and this one will be fetched from the parameter.
21
 *
22
 * @internal
23
 */
24
class CompileHasherServicesPass implements CompilerPassInterface
25
{
26
    /**
27
     * {@inheritdoc}
28
     *
29
     * @throws \LogicException If multiple tags at one service exist.
30
     * @throws \LogicException If no appropriate tag is given.
31
     * @throws \LogicException If no alias is given.
32
     */
33 11
    public function process(ContainerBuilder $container)
34
    {
35 11
        if (!$container->hasParameter('ma27_api_key_authentication.password_hashing_service')) {
36 1
            return;
37
        }
38
39 10
        $alias = $container->getParameter('ma27_api_key_authentication.password_hashing_service');
40 10
        foreach ($container->findTaggedServiceIds('ma27_api_key_authentication.password_hasher') as $id => $tags) {
41 10
            if (count($tags) > 1) {
42 1
                throw new \LogicException(sprintf(
43 1
                    'Service "%s" can have the tag "%s" only one time!',
44 1
                    $id,
45
                    'ma27_api_key_authentication.password_hasher'
46 1
                ));
47
            }
48
49 9
            if (!array_key_exists('alias', $tags[0])) {
50 1
                throw new \LogicException(sprintf(
51 1
                    'The tag "%s" on service "%s" needs an `alias` property!',
52 1
                    'ma27_api_key_authentication.password_hasher',
53
                    $id
54 1
                ));
55
            }
56
57 8
            if ($tags[0]['alias'] === $alias) {
58 7
                $container->setAlias('ma27_api_key_authentication.password.strategy', $id);
59 7
                return;
60
            }
61 6
        }
62
63 1
        throw new \LogicException(sprintf(
64 1
            'No service found for hashing alias "%s"!',
65
            $alias
66 1
        ));
67
    }
68
}
69