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

JWKSet::createDefinition()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

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