ClientRuleSource   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 32
rs 10
c 0
b 0
f 0
wmc 7

5 Methods

Rating   Name   Duplication   Size   Complexity  
A prepend() 0 3 1
A getNodeDefinition() 0 2 1
A name() 0 3 1
A load() 0 8 2
A build() 0 6 2
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * The MIT License (MIT)
7
 *
8
 * Copyright (c) 2014-2019 Spomky-Labs
9
 *
10
 * This software may be modified and distributed under the terms
11
 * of the MIT license.  See the LICENSE file for details.
12
 */
13
14
namespace OAuth2Framework\ServerBundle\Component\ClientRule;
15
16
use OAuth2Framework\Component\ClientRule\Rule;
17
use OAuth2Framework\ServerBundle\Component\Component;
18
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
19
use Symfony\Component\Config\FileLocator;
20
use Symfony\Component\DependencyInjection\ContainerBuilder;
21
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
22
23
class ClientRuleSource implements Component
24
{
25
    public function name(): string
26
    {
27
        return 'client_rule';
28
    }
29
30
    public function load(array $configs, ContainerBuilder $container): void
31
    {
32
        if (!interface_exists(Rule::class)) {
33
            return;
34
        }
35
        $container->registerForAutoconfiguration(Rule::class)->addTag('oauth2_server_client_rule');
36
        $loader = new PhpFileLoader($container, new FileLocator(__DIR__.'/../../Resources/config/client_rule'));
37
        $loader->load('client_rule.php');
38
    }
39
40
    public function getNodeDefinition(ArrayNodeDefinition $node, ArrayNodeDefinition $rootNode): void
41
    {
42
    }
43
44
    public function prepend(ContainerBuilder $container, array $config): array
45
    {
46
        return [];
47
    }
48
49
    public function build(ContainerBuilder $container): void
50
    {
51
        if (!interface_exists(Rule::class)) {
52
            return;
53
        }
54
        $container->addCompilerPass(new ClientRuleCompilerPass());
55
    }
56
}
57