GrantTypeExtensionsCompilerPass   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 4
c 2
b 0
f 0
lcom 0
cbo 3
dl 0
loc 27
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B process() 0 24 4
1
<?php
2
/**
3
 * @author Boris Guéry <[email protected]>
4
 */
5
6
namespace Bgy\OAuth2ServerBundle\DependencyInjection\Compiler;
7
8
9
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
10
use Symfony\Component\DependencyInjection\ContainerBuilder;
11
use Symfony\Component\DependencyInjection\Reference;
12
13
class GrantTypeExtensionsCompilerPass implements CompilerPassInterface
14
{
15
    public function process(ContainerBuilder $container)
16
    {
17
        if (!$container->hasDefinition('bgy_oauth2_server.authorization_server')) {
18
19
            return;
20
        }
21
22
        $taggedServices = $container->findTaggedServiceIds('bgy_oauth2_server.grant_type_extension');
23
24
        $configurationDefinition = $container
25
            ->getDefinition('bgy_oauth2_server.authorization_server')
26
        ;
27
28
        $grantTypesServices = is_array($configurationDefinition->getArgument(4))
29
            ? $configurationDefinition->getArgument(4)
30
            : []
31
        ;
32
33
        foreach ($taggedServices as $id => $attributes) {
34
            $grantTypesServices[] = new Reference($id);
35
        }
36
37
        $configurationDefinition->replaceArgument(4, $grantTypesServices);
38
    }
39
}
40