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 ( 101d1b...17cb6d )
by
unknown
01:53
created

View   A

Complexity

Total Complexity 31

Size/Duplication

Total Lines 260
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 31
lcom 1
cbo 2
dl 0
loc 260
rs 9.8
c 0
b 0
f 0

16 Methods

Rating   Name   Duplication   Size   Complexity  
D __construct() 0 28 9
A validate() 0 8 2
C toArray() 0 27 7
A getId() 0 4 1
A getProjectId() 0 4 1
A getSource() 0 4 1
A setSource() 0 6 1
A getCampaign() 0 4 1
A setCampaign() 0 6 1
A getKeyword() 0 4 1
A setKeyword() 0 6 1
A getSeoSystem() 0 4 1
A setSeoSystem() 0 6 1
A getUtmMarks() 0 4 1
A setUtmMarks() 0 6 1
A addUtmMark() 0 6 1
1
<?php
2
3
namespace LPTracker\models;
4
5
use LPTracker\exceptions\LPTrackerSDKException;
6
7
/**
8
 * Class View
9
 * @package LPTracker\models
10
 */
11
class View extends Model
12
{
13
14
    /**
15
     * @var integer
16
     */
17
    protected $id;
18
19
    /**
20
     * @var integer
21
     */
22
    protected $projectId;
23
24
    /**
25
     * @var string
26
     */
27
    protected $source;
28
29
    /**
30
     * @var string
31
     */
32
    protected $campaign;
33
34
    /**
35
     * @var string
36
     */
37
    protected $keyword;
38
39
    /**
40
     * @var string
41
     */
42
    protected $seoSystem;
43
44
    /**
45
     * @var array
46
     */
47
    protected $utmMarks = [];
48
49
50
    /**
51
     * View constructor.
52
     *
53
     * @param array $viewData
54
     */
55
    public function __construct(array $viewData = [])
56
    {
57
        if (isset($viewData['id'])) {
58
            $this->id = $viewData['id'];
59
        }
60
        if (isset($viewData['project_id'])) {
61
            $this->projectId = $viewData['project_id'];
62
        }
63
        if (isset($viewData['source'])) {
64
            $this->source = $viewData['source'];
65
        }
66
        if (isset($viewData['campaign'])) {
67
            $this->campaign = $viewData['campaign'];
68
        }
69
        if (isset($viewData['keyword'])) {
70
            $this->keyword = $viewData['keyword'];
71
        }
72
        if (isset($viewData['seo_system'])) {
73
            $this->seoSystem = $viewData['seo_system'];
74
        }
75
        if (isset($viewData['utm'])) {
76
            if (is_array($viewData['utm'])) {
77
                $this->utmMarks = $viewData['utm'];
78
            } else {
79
                $this->utmMarks = [ $viewData['utm'] ];
80
            }
81
        }
82
    }
83
84
85
    /**
86
     * @return bool
87
     * @throws LPTrackerSDKException
88
     */
89
    public function validate()
90
    {
91
        if (empty($this->projectId)) {
92
            throw new LPTrackerSDKException('Project ID is required');
93
        }
94
95
        return true;
96
    }
97
98
99
    /**
100
     * @return array
101
     */
102
    public function toArray()
103
    {
104
        $result = [
105
            'project_id' => $this->getProjectId(),
106
        ];
107
108
        if ( ! empty($this->id)) {
109
            $result['id'] = $this->getId();
110
        }
111
        if ( ! empty($this->source)) {
112
            $result['source'] = $this->getSource();
113
        }
114
        if ( ! empty($this->campaign)) {
115
            $result['campaign'] = $this->getCampaign();
116
        }
117
        if ( ! empty($this->keyword)) {
118
            $result['keyword'] = $this->getKeyword();
119
        }
120
        if ( ! empty($this->seoSystem)) {
121
            $result['seo_system'] = $this->getSeoSystem();
122
        }
123
        if ( ! empty($this->utmMarks)) {
124
            $result['utm'] = $this->getUtmMarks();
125
        }
126
127
        return $result;
128
    }
129
130
131
    /**
132
     * @return int
133
     */
134
    public function getId()
135
    {
136
        return $this->id;
137
    }
138
139
140
    /**
141
     * @return int
142
     */
143
    public function getProjectId()
144
    {
145
        return $this->projectId;
146
    }
147
148
149
    /**
150
     * @return string
151
     */
152
    public function getSource()
153
    {
154
        return $this->source;
155
    }
156
157
158
    /**
159
     * @param string $source
160
     *
161
     * @return $this
162
     */
163
    public function setSource($source)
164
    {
165
        $this->source = $source;
166
167
        return $this;
168
    }
169
170
171
    /**
172
     * @return string
173
     */
174
    public function getCampaign()
175
    {
176
        return $this->campaign;
177
    }
178
179
180
    /**
181
     * @param string $campaign
182
     *
183
     * @return $this
184
     */
185
    public function setCampaign($campaign)
186
    {
187
        $this->campaign = $campaign;
188
189
        return $this;
190
    }
191
192
193
    /**
194
     * @return string
195
     */
196
    public function getKeyword()
197
    {
198
        return $this->keyword;
199
    }
200
201
202
    /**
203
     * @param string $keyword
204
     *
205
     * @return $this
206
     */
207
    public function setKeyword($keyword)
208
    {
209
        $this->keyword = $keyword;
210
211
        return $this;
212
    }
213
214
215
    /**
216
     * @return string
217
     */
218
    public function getSeoSystem()
219
    {
220
        return $this->seoSystem;
221
    }
222
223
224
    /**
225
     * @param string $seoSystem
226
     *
227
     * @return $this
228
     */
229
    public function setSeoSystem($seoSystem)
230
    {
231
        $this->seoSystem = $seoSystem;
232
233
        return $this;
234
    }
235
236
237
    /**
238
     * @return array
239
     */
240
    public function getUtmMarks()
241
    {
242
        return $this->utmMarks;
243
    }
244
245
246
    /**
247
     * @param array $utmMarks
248
     *
249
     * @return $this
250
     */
251
    public function setUtmMarks($utmMarks)
252
    {
253
        $this->utmMarks = $utmMarks;
254
255
        return $this;
256
    }
257
258
259
    /**
260
     * @param $mark
261
     *
262
     * @return $this
263
     */
264
    public function addUtmMark($mark)
265
    {
266
        $this->utmMarks[] = $mark;
267
268
        return $this;
269
    }
270
}