Completed
Push — master ( 80d5dd...e32bbf )
by Vladimir
03:02
created

ContainerAwareCommand::getContainer()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 17
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 0
loc 17
ccs 0
cts 10
cp 0
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 7
nc 3
nop 0
crap 12
1
<?php
2
3
/**
4
 * @copyright 2017 Vladimir Jimenez
5
 * @license   https://github.com/allejo/stakx/blob/master/LICENSE.md MIT
6
 */
7
8
namespace allejo\stakx\Command;
9
10
use allejo\stakx\Core\Application;
11
use Symfony\Component\Console\Command\Command;
12
13
abstract class ContainerAwareCommand extends Command
14
{
15
    private $container;
16
17
    public function getContainer()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
18
    {
19
        if ($this->container === null)
20
        {
21
            /** @var Application $application */
22
            $application = $this->getApplication();
23
24
            if ($application === null)
25
            {
26
                throw new \LogicException('The container cannot be retrieved as the application instance is not yet set.');
27
            }
28
29
            $this->container = $application->getContainer();
30
        }
31
32
        return $this->container;
33
    }
34
}