Failed Conditions
Push — ng ( 941bba...49c420 )
by Florent
14:14
created

TrustedIssuerSource::load()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 3
nc 2
nop 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\Component\Core;
15
16
use OAuth2Framework\Bundle\Component\Component;
17
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
18
use Symfony\Component\DependencyInjection\ContainerBuilder;
19
20
class TrustedIssuerSource implements Component
21
{
22
    /**
23
     * {@inheritdoc}
24
     */
25
    public function name(): string
26
    {
27
        return 'trusted_issuer';
28
    }
29
30
    /**
31
     * {@inheritdoc}
32
     */
33
    public function load(array $configs, ContainerBuilder $container)
34
    {
35
        if (null !== $configs['trusted_issuer']['repository']) {
36
            $container->setAlias('oauth2_server.trusted_issuer_repository', $configs['trusted_issuer']['repository']);
37
        }
38
    }
39
40
    /**
41
     * {@inheritdoc}
42
     */
43
    public function getNodeDefinition(ArrayNodeDefinition $node, ArrayNodeDefinition $rootNode)
44
    {
45
        $node->children()
46
            ->arrayNode($this->name())
47
                ->addDefaultsIfNotSet()
48
                ->children()
49
                    ->scalarNode('repository')
50
                        ->info('If set, trusted issuer support will be enabled')
51
                        ->defaultNull()
52
                    ->end()
53
                ->end()
54
            ->end()
55
        ->end();
56
    }
57
58
    /**
59
     * {@inheritdoc}
60
     */
61
    public function build(ContainerBuilder $container)
62
    {
63
        //Nothing to do
64
    }
65
66
    /**
67
     * {@inheritdoc}
68
     */
69
    public function prepend(ContainerBuilder $container, array $config): array
70
    {
71
        //Nothing to do
72
        return [];
73
    }
74
}
75