ProjectExtension::initialize()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
eloc 1
nc 1
nop 1
1
<?php
2
3
namespace Openl10n\Cli\ServiceContainer\Extension;
4
5
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
8
class ProjectExtension implements ConfiguredExtension
9
{
10
    /**
11
     * {@inheritdoc}
12
     */
13
    public function initialize(ContainerBuilder $container)
14
    {
15
    }
16
17
    /**
18
     * {@inheritdoc}
19
     */
20
    public function load(array $config, ContainerBuilder $container)
21
    {
22
        $container
23
            ->register('project_handler', 'Openl10n\Cli\Project\ProjectHandler')
24
            ->addArgument($config['slug'])
25
        ;
26
    }
27
28
    /**
29
     * {@inheritdoc}
30
     */
31
    public function configure(ArrayNodeDefinition $node)
32
    {
33
        $node
34
            ->beforeNormalization()
35
            ->ifString()
36
                ->then(function ($v) { return array(
37
                    'slug' => $v
38
                ); })
39
            ->end()
40
            ->children()
41
                ->scalarNode('slug')
42
                    ->isRequired()
43
                    ->cannotBeEmpty()
44
                ->end()
45
            ->end();
46
    }
47
48
    /**
49
     * {@inheritdoc}
50
     */
51
    public function getName()
52
    {
53
        return 'project';
54
    }
55
}
56