Passed
Pull Request — master (#205)
by Aydin
02:04
created

ItemStyleTrait::setDisplaysExtra()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

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