Passed
Pull Request — master (#203)
by
unknown
02:08
created

SplitStyle   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 20
c 1
b 0
f 0
dl 0
loc 61
rs 10
wmc 7

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getDisplaysExtra() 0 3 1
A getItemExtra() 0 3 1
A toArray() 0 5 1
A __construct() 0 4 1
A fromArray() 0 6 1
A setItemExtra() 0 5 1
A setDisplaysExtra() 0 5 1
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