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

Element   A

Complexity

Total Complexity 13

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 13
lcom 1
cbo 0
dl 0
loc 62
ccs 0
cts 30
cp 0
rs 10
c 0
b 0
f 0

7 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
B reset() 0 21 7
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
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