Failed Conditions
Push — ng ( c00098...4b490a )
by Florent
06:57
created

KeySet::build()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 1
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;
15
16
use Jose\Bundle\JoseFramework\Helper\ConfigurationHelper;
17
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
18
use Symfony\Component\DependencyInjection\ContainerBuilder;
19
20
class KeySet implements Component
0 ignored issues
show
Bug introduced by
There is one abstract method load in this class; you could implement it, or declare this class as abstract.
Loading history...
21
{
22
    /**
23
     * {@inheritdoc}
24
     */
25
    public function name(): string
26
    {
27
        return 'key_set';
28
    }
29
30
    /**
31
     * {@inheritdoc}
32
     */
33
    public function getNodeDefinition(NodeDefinition $node)
34
    {
35
        $node
36
            ->addDefaultsIfNotSet()
37
            ->children()
38
                ->scalarNode('signature')->defaultNull()->end()
39
                ->scalarNode('encryption')->defaultNull()->end()
40
            ->end();
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46
    public function build(ContainerBuilder $container)
47
    {
48
        //Nothing to do
49
    }
50
51
    /**
52
     * {@inheritdoc}
53
     */
54
    public function prepend(ContainerBuilder $container, array $config): array
55
    {
56
        if (null !== $config['key_set']['signature']) {
57
            ConfigurationHelper::addKeyset($container, 'oauth2_server.key_set.signature', 'jwkset', ['value' => $config['key_set']['signature']]);
58
        }
59
        if (null !== $config['key_set']['encryption']) {
60
            ConfigurationHelper::addKeyset($container, 'oauth2_server.key_set.encryption', 'jwkset', ['value' => $config['key_set']['encryption']]);
61
        }
62
63
        return [];
64
    }
65
}
66