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 ( 2e6ed1...3999e5 )
by Sergey
01:18
created

ContactField::getContactId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace LPTracker\models;
4
5
use LPTracker\exceptions\LPTrackerSDKException;
6
7
class ContactField extends Model
8
{
9
    const TYPE_STRING = 'string';
10
    const TYPE_TEXT = 'text';
11
    const TYPE_DATE = 'date';
12
    const TYPE_NUMBER = 'number';
13
14
    /**
15
     * @var integer
16
     */
17
    protected $id;
18
19
    /**
20
     * @var integer
21
     */
22
    protected $contactId;
23
24
    /**
25
     * @var string
26
     */
27
    protected $name;
28
29
    /**
30
     * @var string
31
     */
32
    protected $type;
33
34
    /**
35
     * @var mixed
36
     */
37
    protected $value;
38
39 View Code Duplication
    public function __construct(array $fieldData = [])
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...
40
    {
41
        if (isset($fieldData['id'])) {
42
            $this->id = $fieldData['id'];
43
        }
44
        if (isset($fieldData['contact_id'])) {
45
            $this->contactId = $fieldData['contact_id'];
46
        }
47
        if (isset($fieldData['name'])) {
48
            $this->name = $fieldData['name'];
49
        }
50
        if (isset($fieldData['type'])) {
51
            $this->type = $fieldData['type'];
52
        }
53
        if (isset($fieldData['value'])) {
54
            $this->value = $fieldData['value'];
55
        }
56
    }
57
58
    /**
59
     * @return array
60
     */
61
    public static function getAllTypes()
62
    {
63
        return [
64
            self::TYPE_STRING,
65
            self::TYPE_TEXT,
66
            self::TYPE_DATE,
67
            self::TYPE_NUMBER,
68
        ];
69
    }
70
71
    /**
72
     * @return bool
73
     * @throws LPTrackerSDKException
74
     */
75
    public function validate()
76
    {
77
        if (empty($this->id)) {
78
            throw new LPTrackerSDKException('Field ID is required');
79
        }
80
81
        return true;
82
    }
83
84
    /**
85
     * @return array
86
     */
87 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...
88
    {
89
        $result = [
90
            'id' => $this->id,
91
            'name' => $this->name,
92
            'type' => $this->type,
93
        ];
94
        if (!empty($this->value)) {
95
            $result['value'] = $this->getValue();
96
        }
97
        return $result;
98
    }
99
100
    /**
101
     * @return int
102
     */
103
    public function getId()
104
    {
105
        return $this->id;
106
    }
107
108
    /**
109
     * @return string
110
     */
111
    public function getName()
112
    {
113
        return $this->name;
114
    }
115
116
    /**
117
     * @return string
118
     */
119
    public function getType()
120
    {
121
        return $this->type;
122
    }
123
124
    /**
125
     * @return mixed
126
     */
127
    public function getValue()
128
    {
129
        return $this->value;
130
    }
131
132
    /**
133
     * @param mixed $value
134
     * @return $this
135
     */
136
    public function setValue($value)
137
    {
138
        $this->value = $value;
139
        return $this;
140
    }
141
142
    /**
143
     * @return int
144
     */
145
    public function getContactId()
146
    {
147
        return $this->contactId;
148
    }
149
}
150