Completed
Push — master ( df8184...e3b994 )
by Aydin
02:31
created

SplitItemBuilder::getMenuStyle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace PhpSchool\CliMenu\Builder;
4
5
use PhpSchool\CliMenu\CliMenu;
6
use PhpSchool\CliMenu\MenuItem\SplitItem;
7
use PhpSchool\CliMenu\MenuStyle;
8
use PhpSchool\Terminal\Terminal;
9
10
/**
11
 * @author Aydin Hassan <[email protected]>
12
 */
13
class SplitItemBuilder implements Builder
14
{
15
    use BuilderUtils;
16
17
    public function __construct(Builder $parent)
18
    {
19
        $this->parent = $parent;
0 ignored issues
show
Bug introduced by Aydin Hassan
The property parent does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
20
    }
21
22
    public function build() : SplitItem
23
    {
24
        $items = $this->buildSubMenus($this->menuItems);
25
        
26
        return new SplitItem($items);
27
    }
28
29
    public function setSubMenuParents(CliMenu $menu) : void
30
    {
31
        foreach ($this->subMenus as $subMenu) {
32
            $subMenu->setParent($menu);
33
        }
34
    }
35
36
    public function getTerminal() : Terminal
37
    {
38
        return $this->parent->getTerminal();
39
    }
40
41
    public function getMenuStyle() : MenuStyle
42
    {
43
        return $this->parent->getMenuStyle();
44
    }
45
46
    public function end() : CliMenuBuilder
47
    {
48
        return $this->parent;
49
    }
50
}
51