Completed
Push — master ( 4e457c...e6ff17 )
by Gabriel
02:37
created

Annotation   A

Complexity

Total Complexity 17

Size/Duplication

Total Lines 81
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 17
lcom 1
cbo 0
dl 0
loc 81
ccs 0
cts 40
cp 0
rs 10
c 0
b 0
f 0

10 Methods

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