JWKSets   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 3
dl 0
loc 43
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getKeySet() 0 4 1
A createDefinition() 0 14 2
A addConfiguration() 0 11 1
1
<?php
2
3
/*
4
 * The MIT License (MIT)
5
 *
6
 * Copyright (c) 2014-2016 Spomky-Labs
7
 *
8
 * This software may be modified and distributed under the terms
9
 * of the MIT license.  See the LICENSE file for details.
10
 */
11
12
namespace SpomkyLabs\JoseBundle\DependencyInjection\Source\JWKSetSource;
13
14
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
15
use Symfony\Component\DependencyInjection\ContainerBuilder;
16
use Symfony\Component\DependencyInjection\Definition;
17
use Symfony\Component\DependencyInjection\Reference;
18
19
final class JWKSets extends AbstractJWKSetSource
20
{
21
    /**
22
     * {@inheritdoc}
23
     */
24
    public function createDefinition(ContainerBuilder $container, array $config)
25
    {
26
        $definition = new Definition('Jose\Object\JWKSet');
27
        $definition->setFactory([
28
            new Reference('jose.factory.jwk'),
29
            'createKeySets',
30
        ]);
31
        foreach ($config['id'] as $key_set_id) {
32
            $ref = new Reference($key_set_id);
33
            $definition->addMethodCall('addKeySet', [$ref]);
34
        }
35
36
        return $definition;
37
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42
    public function getKeySet()
43
    {
44
        return 'jwksets';
45
    }
46
47
    /**
48
     * {@inheritdoc}
49
     */
50
    public function addConfiguration(NodeDefinition $node)
51
    {
52
        parent::addConfiguration($node);
53
        $node
54
            ->children()
55
                ->arrayNode('id')
56
                    ->prototype('scalar')->end()
57
                    ->isRequired()
58
                ->end()
59
            ->end();
60
    }
61
}
62