Completed
Pull Request — master (#203)
by
unknown
02:10
created

ItemStyleTrait::getMarker()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 2
eloc 1
c 1
b 1
f 0
nc 2
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
namespace PhpSchool\CliMenu\Style;
4
5
trait ItemStyleTrait
6
{
7
    /**
8
     * @var string
9
     */
10
    protected $markerOn;
11
12
    /**
13
     * @var string
14
     */
15
    protected $markerOff;
16
17
    /**
18
     * @var string
19
     */
20
    protected $itemExtra;
21
22
    /**
23
     * @var bool
24
     */
25
    protected $displaysExtra;
26
27
    protected $custom = false;
28
29
    public function getIsCustom() : bool
30
    {
31
        return $this->custom;
32
    }
33
34
    public function getMarker(bool $selected) : string
35
    {
36
        return $selected ? $this->markerOn : $this->markerOff;
37
    }
38
39
    public function getMarkerOn() : string
40
    {
41
        return $this->markerOn;
42
    }
43
44
    public function setMarkerOn(string $marker) : self
45
    {
46
        $this->custom = true;
47
48
        $this->markerOn = $marker;
49
50
        return $this;
51
    }
52
53
    public function getMarkerOff() : string
54
    {
55
        return $this->markerOff;
56
    }
57
58
    public function setMarkerOff(string $marker) : self
59
    {
60
        $this->custom = true;
61
62
        $this->markerOff = $marker;
63
64
        return $this;
65
    }
66
67
    public function getItemExtra() : string
68
    {
69
        return $this->itemExtra;
70
    }
71
72
    public function setItemExtra(string $itemExtra) : self
73
    {
74
        $this->custom = true;
75
76
        $this->itemExtra = $itemExtra;
77
78
        // if we customise item extra, it means we most likely want to display it
79
        $this->setDisplaysExtra(true);
80
81
        return $this;
82
    }
83
84
    public function getDisplaysExtra() : bool
85
    {
86
        return $this->displaysExtra;
87
    }
88
89
    public function setDisplaysExtra(bool $displaysExtra) : self
90
    {
91
        $this->custom = true;
92
93
        $this->displaysExtra = $displaysExtra;
94
95
        return $this;
96
    }
97
}
98