Completed
Branch master (7673a8)
by VEBER
03:49
created

Kernel::buildContainer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
rs 9.4286
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
/**
4
 * This file is part of the CLIFramework package.
5
 *
6
 * (c) Arnaud VEBER <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace CLIFramework;
13
14
use Symfony\Component\Config\Loader\LoaderInterface;
15
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
16
17
/**
18
 * Kernel.
19
 */
20
class Kernel extends BaseKernel
21
{
22
    /**
23
     * Construct the kernel.
24
     *
25
     * @param string $environment
26
     * @param boolean $debug
27
     *
28
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
29
     */
30
    public function __construct($environment, $debug)
31
    {
32
        parent::__construct($environment, $debug);
33
34
        // boot kernel
35
        $this->boot();
36
    }
37
38
    /**
39
     * Register bundles.
40
     *
41
     * @return array
0 ignored issues
show
Documentation introduced by
Consider making the return type a bit more specific; maybe use \Symfony\Bundle\MonologBundle\MonologBundle[].

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
42
     */
43
    public function registerBundles()
44
    {
45
        // register bundles for every environment
46
        $bundles = array(
47
            new \Symfony\Bundle\MonologBundle\MonologBundle(),
48
        );
49
50
        // register bundles for dev & test environment only
51
        if (in_array($this->getEnvironment(), array('dev', 'test'), true)) {
0 ignored issues
show
Unused Code introduced by
This if statement is empty and can be removed.

This check looks for the bodies of if statements that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.

These if bodies can be removed. If you have an empty if but statements in the else branch, consider inverting the condition.

if (rand(1, 6) > 3) {
//print "Check failed";
} else {
    print "Check succeeded";
}

could be turned into

if (rand(1, 6) <= 3) {
    print "Check succeeded";
}

This is much more concise to read.

Loading history...
52
        }
53
54
        return $bundles;
55
    }
56
57
    /**
58
     * Builds the service container.
59
     *
60
     * @return \Symfony\Component\DependencyInjection\TaggedContainerInterface The compiled service container
0 ignored issues
show
Documentation introduced by
Consider making the return type a bit more specific; maybe use \Symfony\Component\Depen...ection\ContainerBuilder.

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
61
     *
62
     * @throws \RuntimeException
63
     */
64
    protected function buildContainer()
65
    {
66
        $container = parent::buildContainer();
67
        $container->setParameter('app.command.ids', array_keys($container->findTaggedServiceIds('app.command')));
68
69
        return $container;
70
    }
71
72
    /**
73
     * Register container configuration.
74
     *
75
     * @param \Symfony\Component\Config\Loader\LoaderInterface $loader
76
     *
77
     * @return void
78
     */
79
    public function registerContainerConfiguration(LoaderInterface $loader)
80
    {
81
        $loader->load(sprintf('%s/config/%s/config.yml', $this->getRootDir(), $this->getEnvironment()));
82
    }
83
}
84