Failed Conditions
Push — master ( d40a11...28d61e )
by Florent
07:16
created

ConsoleSource::getCompilerPasses()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * The MIT License (MIT)
7
 *
8
 * Copyright (c) 2014-2018 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\NodeDefinition;
19
use Symfony\Component\Config\FileLocator;
20
use Symfony\Component\DependencyInjection\ContainerBuilder;
21
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
22
23
class ConsoleSource implements Source
24
{
25
    /**
26
     * {@inheritdoc}
27
     */
28
    public function name(): string
29
    {
30
        return 'console';
31
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36
    public function load(array $configs, ContainerBuilder $container)
37
    {
38
        if (!$this->isEnabled()) {
39
            return;
40
        }
41
        $loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../../../Resources/config'));
42
        $loader->load('commands.yml');
43
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48
    public function getNodeDefinition(NodeDefinition $node)
49
    {
50
    }
51
52
    /**
53
     * {@inheritdoc}
54
     */
55
    public function prepend(ContainerBuilder $container, array $config): array
56
    {
57
        return [];
58
    }
59
60
    /**
61
     * @return bool
62
     */
63
    private function isEnabled(): bool
64
    {
65
        return class_exists(EcKeyGeneratorCommand::class);
66
    }
67
}
68