TreeItemTrait::getChildren()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
1
<?php
2
3
namespace WebComplete\core\utils\tree;
4
5
use WebComplete\core\entity\AbstractEntity;
6
7
trait TreeItemTrait
8
{
9
    /** @var self|null */
10
    protected $parent;
11
    /** @var self[] */
12
    protected $children = [];
13
14
    /**
15
     * @param self|AbstractEntity $item
16
     */
17
    public function setParent(AbstractEntity $item)
18
    {
19
        $this->parent = $item;
0 ignored issues
show
Documentation Bug introduced by
It seems like $item of type WebComplete\core\entity\AbstractEntity is incompatible with the declared type null|WebComplete\core\utils\tree\TreeItemTrait 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...
20
    }
21
22
    /**
23
     * @return self|null
24
     */
25
    public function getParent()
26
    {
27
        return $this->parent;
28
    }
29
30
    /**
31
     * @param self|AbstractEntity $item
32
     */
33
    public function addChild(AbstractEntity $item)
34
    {
35
        $this->children[$item->getId()] = $item;
36
    }
37
38
    /**
39
     * @return self[]
40
     */
41
    public function getChildren(): array
42
    {
43
        return $this->children;
44
    }
45
}
46