Completed
Push — master ( b2620d...cacd0e )
by Gabriel
02:27
created

Code   A

Complexity

Total Complexity 16

Size/Duplication

Total Lines 76
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 16
lcom 1
cbo 0
dl 0
loc 76
ccs 0
cts 38
cp 0
rs 10
c 0
b 0
f 0

9 Methods

Rating   Name   Duplication   Size   Complexity  
A getId() 0 4 1
A getLabel() 0 4 1
A getValue() 0 4 1
A getCreationDatetime() 0 4 1
A getModificationDatetime() 0 4 1
C reset() 0 24 8
A setLabel() 0 4 1
A setValue() 0 4 1
A jsonSerialize() 0 7 1
1
<?php
2
3
namespace Waredesk\Models\Product\Variant;
4
5
use DateTime;
6
use JsonSerializable;
7
8
class Code implements JsonSerializable
9
{
10
    private $id;
11
    private $label;
12
    private $value;
13
    private $creation_datetime;
14
    private $modification_datetime;
15
16
    public function getId(): ?int
17
    {
18
        return $this->id;
19
    }
20
21
    public function getLabel(): ?string
22
    {
23
        return $this->label;
24
    }
25
26
    public function getValue(): ?string
27
    {
28
        return $this->value;
29
    }
30
31
    public function getCreationDatetime(): ?DateTime
32
    {
33
        return $this->creation_datetime;
34
    }
35
36
    public function getModificationDatetime(): ?DateTime
37
    {
38
        return $this->modification_datetime;
39
    }
40
41
    public function reset(array $data = null)
42
    {
43
        if ($data) {
44
            foreach ($data as $key => $value) {
45
                switch ($key) {
46
                    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...
47
                        $this->id = $value;
48
                        break;
49
                    case 'label':
50
                        $this->label = $value;
51
                        break;
52
                    case 'value':
53
                        $this->value = $value;
54
                        break;
55
                    case 'creation_datetime':
56
                        $this->creation_datetime = $value;
57
                        break;
58
                    case 'modification_datetime':
59
                        $this->modification_datetime = $value;
60
                        break;
61
                }
62
            }
63
        }
64
    }
65
66
    public function setLabel(string $label)
67
    {
68
        $this->label = $label;
69
    }
70
71
    public function setValue(string $value)
72
    {
73
        $this->value = $value;
74
    }
75
76
    public function jsonSerialize()
77
    {
78
        return [
79
            'label' => $this->getLabel(),
80
            'value' => $this->getValue(),
81
        ];
82
    }
83
}
84