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
|
|
|
/** |
46
|
|
|
* View constructor. |
47
|
|
|
* |
48
|
|
|
* @param array $viewData |
49
|
|
|
*/ |
50
|
|
|
public function __construct(array $viewData = []) |
51
|
|
|
{ |
52
|
|
|
if (isset($viewData['id'])) { |
53
|
|
|
$this->id = $viewData['id']; |
54
|
|
|
} |
55
|
|
|
if (isset($viewData['project_id'])) { |
56
|
|
|
$this->projectId = $viewData['project_id']; |
57
|
|
|
} |
58
|
|
|
if (isset($viewData['source'])) { |
59
|
|
|
$this->source = $viewData['source']; |
60
|
|
|
} |
61
|
|
|
if (isset($viewData['campaign'])) { |
62
|
|
|
$this->campaign = $viewData['campaign']; |
63
|
|
|
} |
64
|
|
|
if (isset($viewData['keyword'])) { |
65
|
|
|
$this->keyword = $viewData['keyword']; |
66
|
|
|
} |
67
|
|
|
if (isset($viewData['seo_system'])) { |
68
|
|
|
$this->seoSystem = $viewData['seo_system']; |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* @return bool |
75
|
|
|
* @throws LPTrackerSDKException |
76
|
|
|
*/ |
77
|
|
|
public function validate() |
78
|
|
|
{ |
79
|
|
|
if (empty($this->projectId)) { |
80
|
|
|
throw new LPTrackerSDKException('Project ID is required'); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
return true; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @return array |
89
|
|
|
*/ |
90
|
|
|
public function toArray() |
91
|
|
|
{ |
92
|
|
|
$result = [ |
93
|
|
|
'project_id' => $this->getProjectId(), |
94
|
|
|
]; |
95
|
|
|
|
96
|
|
|
if ( ! empty($this->id)) { |
97
|
|
|
$result['id'] = $this->getId(); |
98
|
|
|
} |
99
|
|
|
if ( ! empty($this->source)) { |
100
|
|
|
$result['source'] = $this->getSource(); |
101
|
|
|
} |
102
|
|
|
if ( ! empty($this->campaign)) { |
103
|
|
|
$result['campaign'] = $this->getCampaign(); |
104
|
|
|
} |
105
|
|
|
if ( ! empty($this->keyword)) { |
106
|
|
|
$result['keyword'] = $this->getKeyword(); |
107
|
|
|
} |
108
|
|
|
if ( ! empty($this->seoSystem)) { |
109
|
|
|
$result['seo_system'] = $this->getSeoSystem(); |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
return $result; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* @return int |
118
|
|
|
*/ |
119
|
|
|
public function getId() |
120
|
|
|
{ |
121
|
|
|
return $this->id; |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
|
125
|
|
|
/** |
126
|
|
|
* @return int |
127
|
|
|
*/ |
128
|
|
|
public function getProjectId() |
129
|
|
|
{ |
130
|
|
|
return $this->projectId; |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
|
134
|
|
|
/** |
135
|
|
|
* @return string |
136
|
|
|
*/ |
137
|
|
|
public function getSource() |
138
|
|
|
{ |
139
|
|
|
return $this->source; |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
|
143
|
|
|
/** |
144
|
|
|
* @param string $source |
145
|
|
|
* |
146
|
|
|
* @return $this |
147
|
|
|
*/ |
148
|
|
|
public function setSource($source) |
149
|
|
|
{ |
150
|
|
|
$this->source = $source; |
151
|
|
|
|
152
|
|
|
return $this; |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
|
156
|
|
|
/** |
157
|
|
|
* @return string |
158
|
|
|
*/ |
159
|
|
|
public function getCampaign() |
160
|
|
|
{ |
161
|
|
|
return $this->campaign; |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
|
165
|
|
|
/** |
166
|
|
|
* @param string $campaign |
167
|
|
|
* |
168
|
|
|
* @return $this |
169
|
|
|
*/ |
170
|
|
|
public function setCampaign($campaign) |
171
|
|
|
{ |
172
|
|
|
$this->campaign = $campaign; |
173
|
|
|
|
174
|
|
|
return $this; |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
|
178
|
|
|
/** |
179
|
|
|
* @return string |
180
|
|
|
*/ |
181
|
|
|
public function getKeyword() |
182
|
|
|
{ |
183
|
|
|
return $this->keyword; |
184
|
|
|
} |
185
|
|
|
|
186
|
|
|
|
187
|
|
|
/** |
188
|
|
|
* @param string $keyword |
189
|
|
|
* |
190
|
|
|
* @return $this |
191
|
|
|
*/ |
192
|
|
|
public function setKeyword($keyword) |
193
|
|
|
{ |
194
|
|
|
$this->keyword = $keyword; |
195
|
|
|
|
196
|
|
|
return $this; |
197
|
|
|
} |
198
|
|
|
|
199
|
|
|
|
200
|
|
|
/** |
201
|
|
|
* @return string |
202
|
|
|
*/ |
203
|
|
|
public function getSeoSystem() |
204
|
|
|
{ |
205
|
|
|
return $this->seoSystem; |
206
|
|
|
} |
207
|
|
|
|
208
|
|
|
|
209
|
|
|
/** |
210
|
|
|
* @param string $seoSystem |
211
|
|
|
* |
212
|
|
|
* @return $this |
213
|
|
|
*/ |
214
|
|
|
public function setSeoSystem($seoSystem) |
215
|
|
|
{ |
216
|
|
|
$this->seoSystem = $seoSystem; |
217
|
|
|
|
218
|
|
|
return $this; |
219
|
|
|
} |
220
|
|
|
} |