Completed
Push — master ( 99cd39...7d74f8 )
by VEBER
02:07
created

Command::getContainer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
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\Console\Command\Command as BaseCommand;
15
16
/**
17
 *
18
 */
19
abstract class Command extends BaseCommand
20
{
21
    /**
22
     * Get kernel.
23
     *
24
     * @return \Symfony\Component\HttpKernel\KernelInterface
25
     *
26
     * @throws \RuntimeException
27
     *
28
     * @codeCoverageIgnore
29
     */
30
    protected function getKernel()
31
    {
32
        $application = $this->getApplication();
33
        if (!$application instanceof \CLIFramework\Application) {
34
            throw new \RuntimeException('Application should be an instance of \CLIFramework\Application');
35
        }
36
37
        return $application->getKernel();
38
    }
39
40
    /**
41
     * Get Container.
42
     *
43
     * @return \Symfony\Component\DependencyInjection\ContainerInterface
44
     *
45
     * @codeCoverageIgnore
46
     */
47
    protected function getContainer()
48
    {
49
        return $this->getKernel()->getContainer();
50
    }
51
}
52