Completed
Pull Request — master (#127)
by Aydin
01:56
created

SplitItemBuilder   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 3
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 33
c 0
b 0
f 0
wmc 6
lcom 3
cbo 3
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A build() 0 6 1
A setSubMenuParents() 0 6 2
A getTerminal() 0 4 1
A getMenuStyle() 0 4 1
1
<?php
2
3
namespace PhpSchool\CliMenu;
4
5
use PhpSchool\CliMenu\MenuItem\SplitItem;
6
use PhpSchool\Terminal\Terminal;
7
8
/**
9
 * @author Aydin Hassan <[email protected]>
10
 */
11
class SplitItemBuilder implements Builder
12
{
13
    use BuilderUtils;
14
15
    public function __construct(Builder $parent)
16
    {
17
        $this->parent = $parent;
18
    }
19
20
    public function build() : SplitItem
21
    {
22
        $items = $this->buildSubMenus($this->menuItems);
23
        
24
        return new SplitItem($items);
25
    }
26
27
    public function setSubMenuParents(CliMenu $menu) : void
28
    {
29
        foreach ($this->subMenus as $subMenu) {
30
            $subMenu->setParent($menu);
31
        }
32
    }
33
34
    public function getTerminal() : Terminal
35
    {
36
        return $this->parent->getTerminal();
37
    }
38
39
    public function getMenuStyle() : MenuStyle
40
    {
41
        return $this->parent->getMenuStyle();
42
    }
43
}
44