Failed Conditions
Push — master ( d9377e...587e80 )
by Florent
02:05
created

JWK::addConfiguration()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * The MIT License (MIT)
7
 *
8
 * Copyright (c) 2014-2017 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 Jose\Bundle\KeyManagement\DependencyInjection\Source\JWKSource;
15
16
use Jose\Bundle\JoseFramework\DependencyInjection\Source\AbstractSource;
17
use Jose\Component\KeyManagement\JWKFactory;
18
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
19
use Symfony\Component\DependencyInjection\ContainerBuilder;
20
use Symfony\Component\DependencyInjection\Definition;
21
use Symfony\Component\DependencyInjection\Reference;
22
23
/**
24
 * Class JWK.
25
 */
26
final class JWK extends AbstractSource implements JWKSourceInterface
27
{
28
    /**
29
     * {@inheritdoc}
30
     */
31
    public function createDefinition(ContainerBuilder $container, array $config): Definition
32
    {
33
        $definition = new Definition(self::class);
34
        $definition->setFactory([
35
            new Reference(JWKFactory::class),
36
            'createFromString',
37
        ]);
38
        $definition->setArguments([
39
            $config['value'],
40
        ]);
41
42
        return $definition;
43
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48
    public function getKey(): string
49
    {
50
        return 'jwk';
51
    }
52
53
    /**
54
     * {@inheritdoc}
55
     */
56
    public function addConfiguration(NodeDefinition $node)
57
    {
58
        parent::addConfiguration($node);
59
        $node
60
            ->children()
61
                ->scalarNode('value')->isRequired()->end()
62
            ->end();
63
    }
64
}
65