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

Element   A

Complexity

Total Complexity 24

Size/Duplication

Total Lines 118
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 73.44%

Importance

Changes 0
Metric Value
wmc 24
lcom 1
cbo 0
dl 0
loc 118
ccs 47
cts 64
cp 0.7344
rs 10
c 0
b 0
f 0

15 Methods

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