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 ( 2c32a2...b98093 )
by
unknown
03:55
created

CustomField::__construct()   F

Complexity

Conditions 11
Paths 1024

Size

Total Lines 43

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 43
rs 3.15
c 0
b 0
f 0
cc 11
nc 1024
nop 1

How to fix   Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace LPTracker\models;
4
5
6
use LPTracker\exceptions\LPTrackerSDKException;
7
8
class CustomField extends Model
9
{
10
11
    protected $id;
12
13
    protected $projectId;
14
15
    protected $name;
16
17
    protected $type;
18
19
    protected $showInLeads;
20
21
    protected $showInDeals;
22
23
    protected $isMultiSelect;
24
25
    protected $isRequired;
26
27
    protected $description;
28
29
    protected $isMultiLine;
30
31
    public function __construct(array $data = [])
32
    {
33
        if (isset($data['id'])) {
34
            $this->id = $data['id'];
35
        }
36
37
        if (isset($data['project_id'])) {
38
            $this->projectId = $data['project_id'];
39
        }
40
41
        if (isset($data['name'])) {
42
            $this->name = $data['name'];
43
        }
44
45
        if (isset($data['type'])) {
46
            $this->type = $data['type'];
47
        }
48
49
        if (isset($data['show_in_leads'])) {
50
            $this->showInLeads = $data['show_in_leads'];
51
        }
52
53
        if (isset($data['show_in_deals'])) {
54
            $this->showInDeals = $data['show_in_deals'];
55
        }
56
57
        if (isset($data['is_multi_select'])) {
58
            $this->isMultiSelect = $data['is_multi_select'];
59
        }
60
61
        if (isset($data['is_required'])) {
62
            $this->isRequired = $data['is_required'];
63
        }
64
65
        if (isset($data['description'])) {
66
            $this->description = $data['description'];
67
        }
68
69
        if (isset($data['is_multi_line'])) {
70
            $this->isMultiLine = $data['is_multi_line'];
71
        }
72
73
    }
74
75
    /**
76
     * @return array
77
     */
78
    public function toArray()
79
    {
80
        return [
81
            'id'              => $this->id,
82
            'project_id'      => $this->projectId,
83
            'name'            => $this->name,
84
            'type'            => $this->type,
85
            'show_in_leads'   => $this->showInLeads,
86
            'show_in_deals'   => $this->showInDeals,
87
            'is_multi_select' => $this->isMultiSelect,
88
            'is_required'     => $this->isRequired,
89
            'description'     => $this->description,
90
            'is_multi_line'   => $this->isMultiLine
91
        ];
92
    }
93
94
    /**
95
     * @return bool
96
     * @throws LPTrackerSDKException
97
     */
98
    public function validate()
99
    {
100
        if (empty($this->id)) {
101
            throw new LPTrackerSDKException('Id is required');
102
        }
103
104
        return true;
105
    }
106
}