Completed
Push — master ( 07c194...4e457c )
by Gabriel
02:39
created

Element::getId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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