Completed
Push — master ( e6ba08...9dbf89 )
by Gabriel
02:34
created

Element::reset()   B

Complexity

Conditions 7
Paths 7

Size

Total Lines 21
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 56

Importance

Changes 0
Metric Value
dl 0
loc 21
ccs 0
cts 16
cp 0
rs 7.551
c 0
b 0
f 0
cc 7
eloc 16
nc 7
nop 1
crap 56
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
14
    public function getId(): ? string
15
    {
16
        return $this->id;
17
    }
18
19
    public function getType(): ? string
20
    {
21
        return $this->type;
22
    }
23
24
    public function getValue(): ? string
25
    {
26
        return $this->value;
27
    }
28
29
    public function getAutoIncrement(): ? bool
30
    {
31
        return $this->auto_increment;
32
    }
33
34
    public function reset(array $data = null)
35
    {
36
        if ($data) {
37
            foreach ($data as $key => $value) {
38
                switch ($key) {
39
                    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...
40
                        $this->id = $value;
41
                        break;
42
                    case 'type':
43
                        $this->type = $value;
44
                        break;
45
                    case 'value':
46
                        $this->value = $value;
47
                        break;
48
                    case 'auto_increment':
49
                        $this->auto_increment = $value;
50
                        break;
51
                }
52
            }
53
        }
54
    }
55
56
    public function setValue(string $value)
57
    {
58
        $this->value = $value;
59
    }
60
61
    public function jsonSerialize()
62
    {
63
        return [
64
            'element' => $this->getId(),
65
            'value' => $this->getValue(),
66
        ];
67
    }
68
}
69