Completed
Push — master ( e6ba08...9dbf89 )
by Gabriel
02:34
created

Element   A

Complexity

Total Complexity 15

Size/Duplication

Total Lines 73
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 78.38%

Importance

Changes 0
Metric Value
wmc 15
lcom 1
cbo 0
dl 0
loc 73
ccs 29
cts 37
cp 0.7838
rs 10
c 0
b 0
f 0

9 Methods

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