Passed
Push — master ( b50380...c789e7 )
by Gabriel
02:38
created

Element::setPadChar()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 3
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 2
1
<?php
2
3
namespace Waredesk\Models\Product\Variant\Code;
4
5
use JsonSerializable;
6
7
class Element implements JsonSerializable
8
{
9
    private $element;
10
    private $type;
11
    private $value;
12
    private $auto_increment;
13
    private $pad_direction;
14
    private $pad_char;
15
    private $pad_length;
16
17
    public function getElement(): ? string
18
    {
19
        return $this->element;
20
    }
21
22
    public function getType(): ? string
23
    {
24
        return $this->type;
25
    }
26
27
    public function getValue(): ? string
28
    {
29
        return $this->value;
30
    }
31
32
    public function getAutoIncrement(): ? bool
33
    {
34
        return $this->auto_increment;
35
    }
36
37
    public function getPadDirection(): ? string
38
    {
39
        return $this->pad_direction;
40
    }
41
42
    public function getPadChar(): ? string
43
    {
44
        return $this->pad_char;
45
    }
46
47
    public function getPadLength(): ? int
48
    {
49
        return $this->pad_length;
50
    }
51
52
    public function reset(array $data = null)
53
    {
54
        if ($data) {
55
            foreach ($data as $key => $value) {
56
                switch ($key) {
57
                    case 'element':
0 ignored issues
show
Coding Style introduced by
case statements should be defined using a colon.

As per the PSR-2 coding standard, case statements should not be wrapped in curly braces. There is no need for braces, since each case is terminated by the next break.

There is also the option to use a semicolon instead of a colon, this is discouraged because many programmers do not even know it works and the colon is universal between programming languages.

switch ($expr) {
    case "A": { //wrong
        doSomething();
        break;
    }
    case "B"; //wrong
        doSomething();
        break;
    case "C": //right
        doSomething();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
58
                        $this->element = $value;
59
                        break;
60
                    case 'type':
61
                        $this->type = $value;
62
                        break;
63
                    case 'value':
64
                        $this->value = $value;
65
                        break;
66
                    case 'auto_increment':
67
                        $this->auto_increment = $value;
68
                        break;
69
                    case 'pad_direction':
70
                        $this->pad_direction = $value;
71
                        break;
72
                    case 'pad_char':
73
                        $this->pad_char = $value;
74
                        break;
75
                    case 'pad_length':
76
                        $this->pad_length = $value;
77
                        break;
78
                }
79
            }
80
        }
81
    }
82
83
    public function setValue(string $value)
84
    {
85
        $this->value = $value;
86
    }
87
88
    public function setAutoIncrement(bool $auto_increment = null)
89
    {
90
        $this->auto_increment = $auto_increment;
91
    }
92
93
    public function setPadDirection(string $pad_direction = null)
94
    {
95
        $this->pad_direction = $pad_direction;
96
    }
97
98
    public function setPadChar(string $pad_char = null)
99
    {
100
        $this->pad_char = $pad_char;
101
    }
102
103
    public function setPadLength(int $pad_length = null)
104
    {
105
        $this->pad_length = $pad_length;
106
    }
107
108
    public function jsonSerialize()
109
    {
110
        return [
111
            'element' => $this->getElement(),
112
            'value' => $this->getValue(),
113
            'auto_increment' => $this->getAutoIncrement(),
114
            'pad_direction' => $this->getPadDirection(),
115
            'pad_char' => $this->getPadChar(),
116
            'pad_length' => $this->getPadLength(),
117
        ];
118
    }
119
}
120