Failed Conditions
Pull Request — master (#47)
by Florent
04:28
created

ConsoleSource::getNodeDefinition()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 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\JoseFramework\DependencyInjection\Source\Console;
15
16
use Jose\Bundle\JoseFramework\DependencyInjection\Source\Source;
17
use Jose\Component\Console\EcKeyGeneratorCommand;
18
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
19
use Symfony\Component\Config\FileLocator;
20
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
21
use Symfony\Component\DependencyInjection\ContainerBuilder;
22
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
23
24
/**
25
 * Class ConsoleSource.
26
 */
27
final class ConsoleSource implements Source
28
{
29
    /**
30
     * {@inheritdoc}
31
     */
32
    public function name(): string
33
    {
34
        return 'console';
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40
    public function load(array $configs, ContainerBuilder $container)
41
    {
42
        if (!$this->isEnabled()) {
43
            return;
44
        }
45
        $loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../../../Resources/config'));
46
        $loader->load('commands.yml');
47
    }
48
49
    /**
50
     * {@inheritdoc}
51
     */
52
    public function getNodeDefinition(ArrayNodeDefinition $node)
53
    {
54
    }
55
56
    /**
57
     * {@inheritdoc}
58
     */
59
    public function prepend(ContainerBuilder $container, array $config): array
60
    {
61
        return [];
62
    }
63
64
    /**
65
     * @return bool
66
     */
67
    private function isEnabled(): bool
68
    {
69
        return class_exists(EcKeyGeneratorCommand::class);
70
    }
71
72
    /**
73
     * @return CompilerPassInterface[]
74
     */
75
    public function getCompilerPasses(): array
76
    {
77
        return [
78
        ];
79
    }
80
}
81