Completed
Push — master ( cda577...82aa13 )
by Christian
02:25
created

CheckAbstract   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 63
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A check() 0 11 1
A setCommandConfig() 0 4 1
A setCommand() 0 4 1
1
<?php
2
3
namespace N98\Magento\Command\System\Check\Env;
4
5
use Adbar\Dot;
6
use N98\Magento\Command\CommandAware;
7
use N98\Magento\Command\CommandConfigAware;
8
use N98\Magento\Command\System\Check\ResultCollection;
9
use N98\Magento\Command\System\Check\SimpleCheck;
10
use N98\Magento\Command\System\CheckCommand;
11
use Symfony\Component\Console\Command\Command;
12
13
abstract class CheckAbstract implements SimpleCheck, CommandAware, CommandConfigAware
14
{
15
    /**
16
     * @var ResultCollection
17
     */
18
    protected $_results;
19
20
    /**
21
     * @var array
22
     */
23
    protected $_commandConfig;
24
25
    /**
26
     * @var CheckCommand
27
     */
28
    protected $_checkCommand;
29
30
    /**
31
     * @var Dot
32
     */
33
    protected $_dot;
34
35
    /**
36
     * @var array
37
     */
38
    protected $_env;
39
40
    /**
41
     * @var string
42
     */
43
    protected $_envFilePath;
44
45
    /**
46
     * @param ResultCollection $results
47
     */
48
    public function check(ResultCollection $results)
49
    {
50
        $this->_results = $results;
51
        $this->_envFilePath = $this->_checkCommand->getApplication()->getMagentoRootFolder() . '/app/etc/env.php';
52
53
        $envArray = include $this->_envFilePath;
54
        $this->_env = $envArray;
55
        $this->_dot = new Dot($envArray);
56
57
        call_user_func([$this, 'checkEnv']);
58
    }
59
60
    /**
61
     * @param array $commandConfig
62
     */
63
    public function setCommandConfig(array $commandConfig)
64
    {
65
        $this->_commandConfig = $commandConfig;
66
    }
67
68
    /**
69
     * @param Command $command
70
     */
71
    public function setCommand(Command $command)
72
    {
73
        $this->_checkCommand = $command;
0 ignored issues
show
Documentation Bug introduced by
$command is of type object<Symfony\Component\Console\Command\Command>, but the property $_checkCommand was declared to be of type object<N98\Magento\Command\System\CheckCommand>. Are you sure that you always receive this specific sub-class here, or does it make sense to add an instanceof check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.

Either this assignment is in error or an instanceof check should be added for that assignment.

class Alien {}

class Dalek extends Alien {}

class Plot
{
    /** @var  Dalek */
    public $villain;
}

$alien = new Alien();
$plot = new Plot();
if ($alien instanceof Dalek) {
    $plot->villain = $alien;
}
Loading history...
74
    }
75
}
76