Completed
Push — master ( 4e457c...e6ff17 )
by Gabriel
02:37
created

Element   A

Complexity

Total Complexity 24

Size/Duplication

Total Lines 117
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 24
lcom 1
cbo 0
dl 0
loc 117
ccs 0
cts 63
cp 0
rs 10
c 0
b 0
f 0

15 Methods

Rating   Name   Duplication   Size   Complexity  
A __clone() 0 3 1
A getElement() 0 4 1
A getType() 0 4 1
A getValue() 0 4 1
A getAutoIncrement() 0 4 1
A getPadDirection() 0 4 1
A getPadChar() 0 4 1
A getPadLength() 0 4 1
D reset() 0 30 10
A setValue() 0 4 1
A setAutoIncrement() 0 4 1
A setPadDirection() 0 4 1
A setPadChar() 0 4 1
A setPadLength() 0 4 1
A jsonSerialize() 0 11 1
1
<?php
2
3
namespace Waredesk\Models\Product\Variant\Code;
4
5
use JsonSerializable;
6
use Waredesk\Entity;
7
8
class Element implements Entity, JsonSerializable
9
{
10
    private $element;
11
    private $type;
12
    private $value;
13
    private $auto_increment;
14
    private $pad_direction;
15
    private $pad_char;
16
    private $pad_length;
17
18
    public function __clone()
19
    {
20
    }
21
22
    public function getElement(): ? string
23
    {
24
        return $this->element;
25
    }
26
27
    public function getType(): ? string
28
    {
29
        return $this->type;
30
    }
31
32
    public function getValue(): ? string
33
    {
34
        return $this->value;
35
    }
36
37
    public function getAutoIncrement(): ? bool
38
    {
39
        return $this->auto_increment;
40
    }
41
42
    public function getPadDirection(): ? string
43
    {
44
        return $this->pad_direction;
45
    }
46
47
    public function getPadChar(): ? string
48
    {
49
        return $this->pad_char;
50
    }
51
52
    public function getPadLength(): ? int
53
    {
54
        return $this->pad_length;
55
    }
56
57
    public function reset(array $data = null)
58
    {
59
        if ($data) {
60
            foreach ($data as $key => $value) {
61
                switch ($key) {
62
                    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...
63
                        $this->element = $value;
64
                        break;
65
                    case 'type':
66
                        $this->type = $value;
67
                        break;
68
                    case 'value':
69
                        $this->value = $value;
70
                        break;
71
                    case 'auto_increment':
72
                        $this->auto_increment = $value;
73
                        break;
74
                    case 'pad_direction':
75
                        $this->pad_direction = $value;
76
                        break;
77
                    case 'pad_char':
78
                        $this->pad_char = $value;
79
                        break;
80
                    case 'pad_length':
81
                        $this->pad_length = $value;
82
                        break;
83
                }
84
            }
85
        }
86
    }
87
88
    public function setValue(string $value)
89
    {
90
        $this->value = $value;
91
    }
92
93
    public function setAutoIncrement(bool $auto_increment = null)
94
    {
95
        $this->auto_increment = $auto_increment;
96
    }
97
98
    public function setPadDirection(string $pad_direction = null)
99
    {
100
        $this->pad_direction = $pad_direction;
101
    }
102
103
    public function setPadChar(string $pad_char = null)
104
    {
105
        $this->pad_char = $pad_char;
106
    }
107
108
    public function setPadLength(int $pad_length = null)
109
    {
110
        $this->pad_length = $pad_length;
111
    }
112
113
    public function jsonSerialize()
114
    {
115
        return [
116
            'element' => $this->getElement(),
117
            'value' => $this->getValue(),
118
            'auto_increment' => $this->getAutoIncrement(),
119
            'pad_direction' => $this->getPadDirection(),
120
            'pad_char' => $this->getPadChar(),
121
            'pad_length' => $this->getPadLength(),
122
        ];
123
    }
124
}
125