SubCommand::parent()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 7
rs 10
1
<?php namespace Tarsana\Command;
2
3
use Tarsana\Command\Command;
4
5
/**
6
 * A SubCommand which has a parent command and can access it.
7
 */
8
class SubCommand extends Command {
9
10
    /**
11
     * The parent command.
12
     *
13
     * @var Tarsana\Command\Command
0 ignored issues
show
Bug introduced by
The type Tarsana\Command\Tarsana\Command\Command was not found. Did you mean Tarsana\Command\Command? If so, make sure to prefix the type with \.
Loading history...
14
     */
15
    protected $parent;
16
17
    /**
18
     * Creates a new SubCommand.
19
     *
20
     * @param Command $parent
21
     */
22
    public function __construct(Command $parent)
23
    {
24
        parent::__construct();
25
        $this->parent($parent)
26
             ->console($parent->console())
27
             ->fs($parent->fs)
28
             ->templatesLoader($parent->templatesLoader);
29
             $this->config = $parent->config;
30
    }
31
32
    /**
33
     * parent getter and setter.
34
     *
35
     * @param  Tarsana\Command\Command|null
36
     * @return Tarsana\Command\Command
37
     */
38
    public function parent(Command $value = null)
39
    {
40
        if (null === $value) {
41
            return $this->parent;
42
        }
43
        $this->parent = $value;
0 ignored issues
show
Documentation Bug introduced by
It seems like $value of type Tarsana\Command\Command is incompatible with the declared type Tarsana\Command\Tarsana\Command\Command of property $parent.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
44
        return $this;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this returns the type Tarsana\Command\SubCommand which is incompatible with the documented return type Tarsana\Command\Tarsana\Command\Command.
Loading history...
45
    }
46
47
}
48