Failed Conditions
Push — master ( 7b0e20...7a5b0d )
by Florent
27:20 queued 25:10
created

AbstractJWKSetSource   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 0
cbo 1
dl 0
loc 32
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 11 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 SpomkyLabs\JoseBundle\DependencyInjection\Source\AbstractSource;
16
17
abstract class AbstractJWKSetSource extends AbstractSource implements JWKSetSourceInterface
18
{
19
    /**
20
     * {@inheritdoc}
21
     */
22
    public function create(ContainerBuilder $container, $id, array $config)
23
    {
24
        parent::create($container, $id, $config);
25
        
26
        if ($config['is_shared']) {
27
            $controller_definition = new Definition('SpomkyLabs\JoseBundle\Controller\JWKSetController');
28
            $controller_definition->setFactory([new Reference('jose.controller.jwkset_controllery_factory'), 'createJWKSetController']);
29
            $controller_definition->setArguments([new Reference($id)]);
30
            $container->setDefinition('jose.controller.'.$id, $controller_definition);
31
        }
32
    }
33
    
34
    /**
35
     * @param \Symfony\Component\Config\Definition\Builder\NodeDefinition $node
36
     */
37
    public function addConfiguration(NodeDefinition $node)
38
    {
39
        parent::addConfiguration($node);
40
        $node
41
            ->children()
42
                ->booleanNode('is_shared')
43
                    ->info('If true, a controller will be created to ease the JWKSet to be shared.')
44
                    ->defaultFalse()
45
                ->end()
46
            ->end();
47
    }
48
}
49