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

SplitStyle::setItemExtra()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 5
rs 10
1
<?php
2
3
namespace PhpSchool\CliMenu\Style;
4
5
class SplitStyle
6
{
7
    /**
8
     * @var string
9
     */
10
    protected $itemExtra;
11
12
    /**
13
     * @var bool
14
     */
15
    protected $displaysExtra;
16
17
    protected const DEFAULT_STYLES = [
18
        'itemExtra'     => '',
19
        'displaysExtra' => false,
20
    ];
21
22
    public function __construct()
23
    {
24
        $this->setItemExtra(self::DEFAULT_STYLES['itemExtra']);
25
        $this->setDisplaysExtra(self::DEFAULT_STYLES['displaysExtra']);
26
    }
27
28
    public function getItemExtra() : string
29
    {
30
        return $this->itemExtra;
31
    }
32
33
    public function setItemExtra(string $itemExtra) : self
34
    {
35
        $this->itemExtra = $itemExtra;
36
37
        return $this;
38
    }
39
40
    public function getDisplaysExtra() : bool
41
    {
42
        return $this->displaysExtra;
43
    }
44
45
    public function setDisplaysExtra(bool $displaysExtra) : self
46
    {
47
        $this->displaysExtra = $displaysExtra;
48
49
        return $this;
50
    }
51
52
    public function toArray() : array
53
    {
54
        return [
55
            'itemExtra'     => $this->itemExtra,
56
            'displaysExtra' => $this->displaysExtra,
57
        ];
58
    }
59
60
    public function fromArray(array $style) : self
61
    {
62
        $this->itemExtra     = $style['itemExtra'] ?? $this->itemExtra;
63
        $this->displaysExtra = $style['displaysExtra'] ?? $this->displaysExtra;
64
65
        return $this;
66
    }
67
}
68