Completed
Push — master ( 9dbf89...b50380 )
by Gabriel
02:57
created

Element   A

Complexity

Total Complexity 19

Size/Duplication

Total Lines 89
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 19
lcom 1
cbo 0
dl 0
loc 89
ccs 0
cts 45
cp 0
rs 10
c 0
b 0
f 0

10 Methods

Rating   Name   Duplication   Size   Complexity  
A getId() 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 jsonSerialize() 0 7 1
1
<?php
2
3
namespace Waredesk\Models\Product\Variant\Code;
4
5
use JsonSerializable;
6
7
class Element implements JsonSerializable
8
{
9
    private $id;
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 getId(): ? string
18
    {
19
        return $this->id;
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 '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...
58
                        $this->id = $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 jsonSerialize()
89
    {
90
        return [
91
            'element' => $this->getId(),
92
            'value' => $this->getValue(),
93
        ];
94
    }
95
}
96