ContainerAwareCommand::getContainer()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 8
ccs 4
cts 4
cp 1
rs 9.4285
cc 2
eloc 4
nc 2
nop 0
crap 2
1
<?php
2
/**
3
 * This file is part of LuisMulinari\Consoleful
4
 *
5
 * @license http://opensource.org/licenses/BSD-3-Clause BSD-3-Clause
6
 */
7
8
namespace LuisMulinari\Consoleful\Command;
9
10
use Symfony\Component\Console\Command\Command;
11
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
12
use Symfony\Component\DependencyInjection\ContainerInterface;
13
14
abstract class ContainerAwareCommand extends Command implements ContainerAwareInterface
15
{
16
    /**
17
     * @var ContainerInterface|null
18
     */
19
    private $container;
20
21
    /**
22
     * @return ContainerInterface
23
     */
24 2
    public function getContainer()
25
    {
26 2
        if (null === $this->container) {
27 1
            throw new \LogicException('The container cannot be retrieved');
28
        }
29
30 1
        return $this->container;
31
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36 1
    public function setContainer(ContainerInterface $container = null)
37
    {
38 1
        $this->container = $container;
39 1
    }
40
}
41