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

Activity   A

Complexity

Total Complexity 21

Size/Duplication

Total Lines 101
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 47.17%

Importance

Changes 0
Metric Value
wmc 21
lcom 1
cbo 0
dl 0
loc 101
ccs 25
cts 53
cp 0.4717
rs 10
c 0
b 0
f 0

13 Methods

Rating   Name   Duplication   Size   Complexity  
A __clone() 0 3 1
A getId() 0 4 1
A getType() 0 4 1
A getNote() 0 4 1
A getDate() 0 4 1
A getCreation() 0 4 1
A getModification() 0 4 1
A setType() 0 4 1
A setNote() 0 4 1
A setDate() 0 4 1
A jsonSerialize() 0 9 1
A __construct() 0 4 1
D reset() 0 27 9
1
<?php
2
3
namespace Waredesk\Models\Inventory\Item;
4
5
use JsonSerializable;
6
use Waredesk\Entity;
7
use DateTime;
8
9
class Activity implements Entity, JsonSerializable
10
{
11
    private $id;
12
    private $type;
13
    private $note;
14
    private $date;
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
    public function getType(): ? string
33
    {
34
        return $this->type;
35
    }
36
37
    public function getNote(): ? string
38
    {
39
        return $this->note;
40
    }
41
42
    public function getDate(): ? DateTime
43
    {
44
        return $this->date;
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 'type':
66 2
                        $this->type = $value;
67 2
                        break;
68 2
                    case 'note':
69 2
                        $this->note = $value;
70 2
                        break;
71 2
                    case 'date':
72 2
                        $this->date = $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
    public function setType(string $type)
86
    {
87
        $this->type = $type;
88
    }
89
90
    public function setNote(string $note)
91
    {
92
        $this->note = $note;
93
    }
94
95
    public function setDate(DateTime $date)
96
    {
97
        $this->date = $date;
98
    }
99
100
    public function jsonSerialize(): array
101
    {
102
        $returnValue = [
103
            'type' => $this->getType(),
104
            'note' => $this->getNote(),
105
            'date' => $this->getDate()->format(DateTime::ATOM),
106
        ];
107
        return $returnValue;
108
    }
109
}
110