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