Completed
Push — master ( 743367...2eb0ee )
by Gabriel
06:30
created

Attribute::getCreation()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
namespace Waredesk\Models\Inventory\Item;
4
5
use DateTime;
6
use JsonSerializable;
7
use Waredesk\Entity;
8
9
class Attribute implements Entity, JsonSerializable
10
{
11
    private $id;
12
    private $item_attribute;
13
    private $name;
14
    private $value;
15
    private $creation;
16
    private $modification;
17
18 2
    public function __construct(array $data = null)
19
    {
20 2
        $this->reset($data);
21 2
    }
22
23
    public function __clone()
24
    {
25
    }
26
27
    public function getId(): ? string
28
    {
29
        return $this->id;
30
    }
31
32 1
    public function getItemAttribute(): ? string
33
    {
34 1
        return $this->item_attribute;
35
    }
36
37
    public function getName(): ? string
38
    {
39
        return $this->name;
40
    }
41
42 1
    public function getValue(): ? string
43
    {
44 1
        return $this->value;
45
    }
46
47
    public function getCreation(): ? DateTime
48
    {
49
        return $this->creation;
50
    }
51
52
    public function getModification(): ? DateTime
53
    {
54
        return $this->modification;
55
    }
56
57 2
    public function reset(array $data = null)
58
    {
59 2
        if ($data) {
60 2
            foreach ($data as $key => $value) {
61
                switch ($key) {
62 2
                    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...
63 2
                        $this->id = $value;
64 2
                        break;
65 2
                    case 'item_attribute':
66 2
                        $this->item_attribute = $value;
67 2
                        break;
68 2
                    case 'name':
69 2
                        $this->name = $value;
70 2
                        break;
71 2
                    case 'value':
72 2
                        $this->value = $value;
73 2
                        break;
74 2
                    case 'creation':
75 2
                        $this->creation = $value;
76 2
                        break;
77 2
                    case 'modification':
78 2
                        $this->modification = $value;
79 2
                        break;
80
                }
81
            }
82
        }
83 2
    }
84
85 1
    public function setItemAttribute(string $item_attribute)
86
    {
87 1
        $this->item_attribute = $item_attribute;
88 1
    }
89
90 1
    public function setValue(string $value)
91
    {
92 1
        $this->value = $value;
93 1
    }
94
95 1
    public function jsonSerialize(): array
96
    {
97
        $returnValue = [
98 1
            'item_attribute' => $this->getItemAttribute(),
99 1
            'value' => $this->getValue(),
100
        ];
101 1
        return $returnValue;
102
    }
103
}
104