Completed
Push — master ( f2c57a...b4ecb3 )
by Gabriel
02:40
created

Category   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 80.95%

Importance

Changes 0
Metric Value
wmc 10
lcom 1
cbo 0
dl 0
loc 45
ccs 17
cts 21
cp 0.8095
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A __clone() 0 3 1
A getId() 0 4 1
A getName() 0 4 1
B reset() 0 15 5
A jsonSerialize() 0 4 1
1
<?php
2
3
namespace Waredesk\Models\Product;
4
5
use JsonSerializable;
6
use Waredesk\Entity;
7
use Waredesk\ReplaceableEntity;
8
9
class Category implements Entity, ReplaceableEntity, JsonSerializable
10
{
11
    private $id;
12
    private $name;
13
14 5
    public function __construct(string $id)
15
    {
16 5
        $this->id = $id;
17 5
    }
18
19
    public function __clone()
20
    {
21
    }
22
23 4
    public function getId(): ? string
24
    {
25 4
        return $this->id;
26
    }
27
28
    public function getName(): ? string
29
    {
30
        return $this->name;
31
    }
32
33 5
    public function reset(array $data = null)
34
    {
35 5
        if ($data) {
36 5
            foreach ($data as $key => $value) {
37
                switch ($key) {
38 5
                    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...
39 5
                        $this->id = $value;
40 5
                        break;
41 5
                    case 'name':
42 5
                        $this->name = $value;
43 5
                        break;
44
                }
45
            }
46
        }
47 5
    }
48
49 4
    public function jsonSerialize(): string
50
    {
51 4
        return $this->getId();
52
    }
53
}
54