JWK   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A createDefinition() 0 14 1
A getKey() 0 4 1
A addConfiguration() 0 12 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * The MIT License (MIT)
7
 *
8
 * Copyright (c) 2014-2019 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\JoseFramework\DependencyInjection\Source\KeyManagement\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
class JWK extends AbstractSource implements JWKSource
24
{
25
    public function createDefinition(ContainerBuilder $container, array $config): Definition
26
    {
27
        $definition = new Definition(\Jose\Component\Core\JWK::class);
28
        $definition->setFactory([
29
            new Reference(JWKFactory::class),
30
            'createFromJsonObject',
31
        ]);
32
        $definition->setArguments([
33
            $config['value'],
34
        ]);
35
        $definition->addTag('jose.jwk');
36
37
        return $definition;
38
    }
39
40
    public function getKey(): string
41
    {
42
        return 'jwk';
43
    }
44
45
    public function addConfiguration(NodeDefinition $node): void
46
    {
47
        parent::addConfiguration($node);
48
        $node
49
            ->children()
50
            ->scalarNode('value')
51
            ->info('The JWK object')
52
            ->isRequired()
53
            ->end()
54
            ->end()
55
        ;
56
    }
57
}
58