Failed Conditions
Push — ng ( 57a3a2...d2fe45 )
by Florent
03:39
created

EndpointSource   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 65
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 2
dl 0
loc 65
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A name() 0 4 1
A load() 0 6 2
A getNodeDefinition() 0 10 2
A prepend() 0 12 2
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * The MIT License (MIT)
7
 *
8
 * Copyright (c) 2014-2018 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\Bundle\DependencyInjection\Component\Endpoint;
15
16
use OAuth2Framework\Bundle\DependencyInjection\Component\Component;
17
use OAuth2Framework\Bundle\DependencyInjection\Component\Endpoint\Token\TokenEndpointSource;
18
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
19
use Symfony\Component\DependencyInjection\ContainerBuilder;
20
21
final class EndpointSource implements Component
22
{
23
    /**
24
     * @var Component[]
25
     */
26
    private $subComponents = [];
27
28
    /**
29
     * EndpointSource constructor.
30
     */
31
    public function __construct()
32
    {
33
        $this->subComponents = [
34
            new TokenEndpointSource(),
35
        ];
36
    }
37
38
    /**
39
     * @return string
40
     */
41
    public function name(): string
42
    {
43
        return 'endpoint';
44
    }
45
46
    /**
47
     * {@inheritdoc}
48
     */
49
    public function load(array $configs, ContainerBuilder $container)
50
    {
51
        foreach ($this->subComponents as $subComponent) {
52
            $subComponent->load($configs, $container);
53
        }
54
    }
55
56
    /**
57
     * {@inheritdoc}
58
     */
59
    public function getNodeDefinition(NodeDefinition $node)
60
    {
61
        $childNode = $node->children()
62
            ->arrayNode($this->name())
63
                ->addDefaultsIfNotSet();
64
65
        foreach ($this->subComponents as $subComponent) {
66
            $subComponent->getNodeDefinition($childNode);
67
        }
68
    }
69
70
    /**
71
     * {@inheritdoc}
72
     */
73
    public function prepend(ContainerBuilder $container, array $config): array
74
    {
75
        $updatedConfig = [];
76
        foreach ($this->subComponents as $subComponent) {
77
            $updatedConfig = array_merge(
78
                $updatedConfig,
79
                $subComponent->prepend($container, $config)
80
            );
81
        }
82
83
        return $updatedConfig;
84
    }
85
}
86