GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 6dbaad...d04f27 )
by Sergey
02:21
created

Category::__construct()   A

Complexity

Conditions 4
Paths 8

Size

Total Lines 12

Duplication

Lines 12
Ratio 100 %

Importance

Changes 0
Metric Value
dl 12
loc 12
rs 9.8666
c 0
b 0
f 0
cc 4
nc 8
nop 1
1
<?php
2
3
namespace LPTracker\models;
4
5
use LPTracker\exceptions\LPTrackerSDKException;
6
7
class Category extends Model
8
{
9
    /**
10
     * @var int
11
     */
12
    protected $id;
13
14
    /**
15
     * @var string
16
     */
17
    protected $name;
18
19
    /**
20
     * @var string
21
     */
22
    protected $color;
23
24 View Code Duplication
    public function __construct(array $categoryData = [])
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
25
    {
26
        if (isset($categoryData['id'])) {
27
            $this->id = (int) $categoryData['id'];
28
        }
29
        if (!empty($categoryData['category'])) {
30
            $this->name = $categoryData['category'];
31
        }
32
        if (!empty($categoryData['purpose'])) {
33
            $this->color = $categoryData['purpose'];
34
        }
35
    }
36
37
    /**
38
     * @return array
39
     */
40 View Code Duplication
    public function toArray()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
41
    {
42
        $result = [];
43
        if (!empty($this->id)) {
44
            $result['id'] = $this->getId();
45
        }
46
        if (!empty($this->name)) {
47
            $result['category'] = $this->getName();
48
        }
49
        if (!empty($this->color)) {
50
            $result['purpose'] = $this->getColor();
51
        }
52
        return $result;
53
    }
54
55
    /**
56
     * @return bool
57
     * @throws LPTrackerSDKException
58
     */
59
    public function validate()
60
    {
61
        if (empty($this->name)) {
62
            throw new LPTrackerSDKException('Category name is required');
63
        }
64
65
        return true;
66
    }
67
68
    /**
69
     * @return int
70
     */
71
    public function getId()
72
    {
73
        return $this->id;
74
    }
75
76
    /**
77
     * @return string
78
     */
79
    public function getName()
80
    {
81
        return $this->name;
82
    }
83
84
    /**
85
     * @param string $name
86
     * @return $this
87
     */
88
    public function setName($name)
89
    {
90
        $this->name = $name;
91
        return $this;
92
    }
93
94
    /**
95
     * @return string
96
     */
97
    public function getColor()
98
    {
99
        return $this->color;
100
    }
101
102
    /**
103
     * @param string $color
104
     * @return $this
105
     */
106
    public function setColor($color)
107
    {
108
        $this->color = $color;
109
        return $this;
110
    }
111
}
112