Completed
Pull Request — master (#68)
by Vladimir
03:57
created

ContainerAwareCommand   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 22
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getContainer() 0 17 3
1
<?php
2
3
/**
4
 * @copyright 2018 Vladimir Jimenez
5
 * @license   https://github.com/stakx-io/stakx/blob/master/LICENSE.md MIT
6
 */
7
8
namespace allejo\stakx\Console\Command;
9
10
use allejo\stakx\Console\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
}
35