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

JKUSource   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A name() 0 4 1
A createService() 0 5 1
A getNodeDefinition() 0 19 1
A prepend() 0 4 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;
15
16
use Jose\Bundle\JoseFramework\DependencyInjection\Source\SourceInterface;
17
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
18
use Symfony\Component\DependencyInjection\ContainerBuilder;
19
20
/**
21
 * Class JKUSource.
22
 */
23
final class JKUSource implements SourceInterface
24
{
25
    /**
26
     * {@inheritdoc}
27
     */
28
    public function name(): string
29
    {
30
        return 'jku_factory';
31
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36
    public function createService(array $config, ContainerBuilder $container)
37
    {
38
        $container->setAlias('jose.http_client', $config['client']);
39
        $container->setAlias('jose.request_factory', $config['request_factory']);
40
    }
41
42
    /**
43
     * {@inheritdoc}
44
     */
45
    public function getNodeDefinition(ArrayNodeDefinition $node)
46
    {
47
        $node
48
            ->children()
49
                ->arrayNode('jku_factory')
50
                    ->canBeEnabled()
51
                    ->children()
52
                        ->scalarNode('client')
53
                            ->info('HTTP Client used to retrieve key sets.')
54
                            ->isRequired()
55
                            ->defaultNull()
56
                        ->end()
57
                        ->scalarNode('request_factory')
58
                            ->defaultValue('Http\Message\MessageFactory\GuzzleMessageFactory')
59
                        ->end()
60
                    ->end()
61
                ->end()
62
            ->end();
63
    }
64
65
    /**
66
     * {@inheritdoc}
67
     */
68
    public function prepend(ContainerBuilder $container, array $config): ?array
69
    {
70
        return null;
71
    }
72
}
73