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 ( f9d0ca...755fa4 )
by
unknown
02:25
created

ContactField::getValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

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