Failed Conditions
Push — ng ( efd567...e5f725 )
by Florent
04:15
created

KeySet   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 0
dl 0
loc 38
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A name() 0 4 1
A getNodeDefinition() 0 9 1
A prepend() 0 11 3
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;
15
16
use Jose\Bundle\JoseFramework\Helper\ConfigurationHelper;
17
use OAuth2Framework\Bundle\DependencyInjection\Component\Component;
18
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
19
use Symfony\Component\DependencyInjection\ContainerBuilder;
20
21
final 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...
22
{
23
    /**
24
     * {@inheritdoc}
25
     */
26
    public function name(): string
27
    {
28
        return 'key_set';
29
    }
30
31
    /**
32
     * {@inheritdoc}
33
     */
34
    public function getNodeDefinition(NodeDefinition $node)
35
    {
36
        $node
37
            ->addDefaultsIfNotSet()
38
            ->children()
39
                ->scalarNode('signature')->defaultNull()->end()
40
                ->scalarNode('encryption')->defaultNull()->end()
41
            ->end();
42
    }
43
44
    /**
45
     * {@inheritdoc}
46
     */
47
    public function prepend(ContainerBuilder $container, array $config): array
48
    {
49
        if (null !== $config['key_set']['signature']) {
50
            ConfigurationHelper::addKeyset($container, 'oauth2_server.key_set.signature', 'jwkset', ['value' => $config['key_set']['signature']]);
51
        }
52
        if (null !== $config['key_set']['encryption']) {
53
            ConfigurationHelper::addKeyset($container, 'oauth2_server.key_set.encryption', 'jwkset', ['value' => $config['key_set']['encryption']]);
54
        }
55
56
        return [];
57
    }
58
}
59