EndpointSource   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 28
c 0
b 0
f 0
dl 0
loc 63
rs 10
wmc 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 12 1
A name() 0 3 1
A load() 0 4 2
A build() 0 4 2
A prepend() 0 11 2
A getNodeDefinition() 0 9 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\Endpoint;
15
16
use OAuth2Framework\ServerBundle\Component\Component;
17
use OAuth2Framework\ServerBundle\Component\Endpoint\Authorization\AuthorizationEndpointSource;
18
use OAuth2Framework\ServerBundle\Component\Endpoint\ClientConfiguration\ClientConfigurationSource;
19
use OAuth2Framework\ServerBundle\Component\Endpoint\ClientRegistration\ClientRegistrationSource;
20
use OAuth2Framework\ServerBundle\Component\Endpoint\JwksUri\JwksUriEndpointSource;
21
use OAuth2Framework\ServerBundle\Component\Endpoint\Metadata\MetadataEndpointSource;
22
use OAuth2Framework\ServerBundle\Component\Endpoint\SessionManagement\SessionManagementEndpointSource;
23
use OAuth2Framework\ServerBundle\Component\Endpoint\Token\TokenEndpointSource;
24
use OAuth2Framework\ServerBundle\Component\Endpoint\TokenIntrospection\TokenIntrospectionEndpointSource;
25
use OAuth2Framework\ServerBundle\Component\Endpoint\TokenRevocation\TokenRevocationEndpointSource;
26
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
27
use Symfony\Component\DependencyInjection\ContainerBuilder;
28
29
class EndpointSource implements Component
30
{
31
    /**
32
     * @var Component[]
33
     */
34
    private $subComponents = [];
35
36
    public function __construct()
37
    {
38
        $this->subComponents = [
39
            new ClientRegistrationSource(),
40
            new ClientConfigurationSource(),
41
            new AuthorizationEndpointSource(),
42
            new TokenEndpointSource(),
43
            new TokenIntrospectionEndpointSource(),
44
            new TokenRevocationEndpointSource(),
45
            new JwksUriEndpointSource(),
46
            new MetadataEndpointSource(),
47
            new SessionManagementEndpointSource(),
48
        ];
49
    }
50
51
    public function name(): string
52
    {
53
        return 'endpoint';
54
    }
55
56
    public function load(array $configs, ContainerBuilder $container): void
57
    {
58
        foreach ($this->subComponents as $subComponent) {
59
            $subComponent->load($configs, $container);
60
        }
61
    }
62
63
    public function getNodeDefinition(ArrayNodeDefinition $node, ArrayNodeDefinition $rootNode): void
64
    {
65
        $childNode = $node->children()
66
            ->arrayNode($this->name())
67
            ->addDefaultsIfNotSet()
68
        ;
69
70
        foreach ($this->subComponents as $subComponent) {
71
            $subComponent->getNodeDefinition($childNode, $node);
72
        }
73
    }
74
75
    public function prepend(ContainerBuilder $container, array $config): array
76
    {
77
        $updatedConfig = [];
78
        foreach ($this->subComponents as $subComponent) {
79
            $updatedConfig = array_merge(
80
                $updatedConfig,
81
                $subComponent->prepend($container, $config)
82
            );
83
        }
84
85
        return $updatedConfig;
86
    }
87
88
    public function build(ContainerBuilder $container): void
89
    {
90
        foreach ($this->subComponents as $component) {
91
            $component->build($container);
92
        }
93
    }
94
}
95