1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @author Oleg Krivtsov <[email protected]> |
4
|
|
|
* @date 06 October 2016 |
5
|
|
|
* @copyright (c) 2016, Web Marketing ROI |
6
|
|
|
*/ |
7
|
|
|
namespace WebMarketingROI\OptimizelyPHP\Resource\v2; |
8
|
|
|
|
9
|
|
|
use WebMarketingROI\OptimizelyPHP\Resource\v2\WebSnippet; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* An Optimizely project. |
13
|
|
|
*/ |
14
|
|
|
class Project |
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* The name of the project |
18
|
|
|
* @var string |
19
|
|
|
*/ |
20
|
|
|
private $name; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* The account the project is associated with |
24
|
|
|
* @var integer |
25
|
|
|
*/ |
26
|
|
|
private $accountId; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* The significance level at which you would like to declare winning and |
30
|
|
|
* losing variations. A lower number minimizes the time needed to declare a |
31
|
|
|
* winning or losing variation, but increases the risk that your results |
32
|
|
|
* aren't true winners and losers. The precision for this number is up to 4 |
33
|
|
|
* decimal places. |
34
|
|
|
* |
35
|
|
|
* @var number |
36
|
|
|
*/ |
37
|
|
|
private $confidenceThreshold; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* The ID of a Dynamic Customer Profile Service associated with this project. |
41
|
|
|
* @var integer |
42
|
|
|
*/ |
43
|
|
|
private $dcpServiceId; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* The platform of the project. Can be 'web', 'ios', 'android' or 'custom'. |
47
|
|
|
* @var string |
48
|
|
|
*/ |
49
|
|
|
private $platform; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* The current status of the project. Can be 'active' or 'archived'. |
53
|
|
|
* @var string |
54
|
|
|
*/ |
55
|
|
|
private $status; |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Web snippet-specific configuration for this project. |
59
|
|
|
* @var WebSnippet |
60
|
|
|
*/ |
61
|
|
|
private $webSnippet; |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* The time that the project was originally created |
65
|
|
|
* @var string |
66
|
|
|
*/ |
67
|
|
|
private $created; |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* The unique identifier for the project. |
71
|
|
|
* @var integer |
72
|
|
|
*/ |
73
|
|
|
private $id; |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* Whether or not this project was created under Optimizely Classic. |
77
|
|
|
* @var boolean |
78
|
|
|
*/ |
79
|
|
|
private $isClassic; |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* The time the project was last modified |
83
|
|
|
* @var string |
84
|
|
|
*/ |
85
|
|
|
private $lastModified; |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* The token used to identify your mobile app to Optimizely. (mobile only) |
89
|
|
|
* @var string |
90
|
|
|
*/ |
91
|
|
|
private $socketToken; |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* Constructor. |
95
|
|
|
*/ |
96
|
7 |
|
public function __construct($options = array()) |
97
|
|
|
{ |
98
|
7 |
|
foreach ($options as $name=>$value) { |
99
|
|
|
switch ($name) { |
100
|
6 |
|
case 'name': $this->setName($value); break; |
|
|
|
|
101
|
6 |
|
case 'account_id': $this->setAccountId($value); break; |
|
|
|
|
102
|
6 |
|
case 'confidence_threshold': $this->setConfidenceThreshold($value); break; |
|
|
|
|
103
|
6 |
|
case 'dcp_service_id': $this->setDcpServiceId($value); break; |
|
|
|
|
104
|
6 |
|
case 'platform': $this->setPlatform($value); break; |
|
|
|
|
105
|
6 |
|
case 'status': $this->setStatus($value); break; |
|
|
|
|
106
|
6 |
|
case 'web_snippet': { |
|
|
|
|
107
|
6 |
|
$webSnippet = new WebSnippet($value); |
108
|
6 |
|
$this->setWebSnippet($webSnippet); |
109
|
6 |
|
break; |
110
|
|
|
} |
111
|
6 |
|
case 'created': $this->setCreated($value); break; |
|
|
|
|
112
|
6 |
|
case 'id': $this->setId($value); break; |
|
|
|
|
113
|
5 |
|
case 'is_classic': $this->setIsClassic($value); break; |
|
|
|
|
114
|
5 |
|
case 'last_modified': $this->setLastModified($value); break; |
|
|
|
|
115
|
5 |
|
case 'socket_token': $this->setSocketToken($value); break; |
|
|
|
|
116
|
|
|
default: |
117
|
|
|
throw new \Exception('Unknown option: ' . $name); |
118
|
|
|
} |
119
|
7 |
|
} |
120
|
7 |
|
} |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* Returns this object as array. |
124
|
|
|
*/ |
125
|
3 |
|
public function toArray() |
126
|
|
|
{ |
127
|
|
|
$options = array( |
128
|
3 |
|
'name' => $this->getName(), |
129
|
3 |
|
'account_id' => $this->getAccountId(), |
130
|
3 |
|
'confidence_threshold' => $this->getConfidenceThreshold(), |
131
|
3 |
|
'dcp_service_id' => $this->getDcpServiceId(), |
132
|
3 |
|
'platform' => $this->getPlatform(), |
133
|
3 |
|
'status' => $this->getStatus(), |
134
|
3 |
|
'web_snippet' => $this->getWebSnippet()?$this->getWebSnippet()->toArray():null, |
135
|
3 |
|
'created' => $this->getCreated(), |
136
|
3 |
|
'id' => $this->getId(), |
137
|
3 |
|
'is_classic' => $this->getIsClassic(), |
138
|
3 |
|
'last_modified' => $this->getLastModified(), |
139
|
3 |
|
'socket_token' => $this->getSocketToken() |
140
|
3 |
|
); |
141
|
|
|
|
142
|
|
|
// Remove options with empty values |
143
|
3 |
|
$cleanedOptions = array(); |
144
|
3 |
|
foreach ($options as $name=>$value) { |
145
|
3 |
|
if ($value!==null) |
146
|
3 |
|
$cleanedOptions[$name] = $value; |
147
|
3 |
|
} |
148
|
|
|
|
149
|
3 |
|
return $cleanedOptions; |
150
|
|
|
} |
151
|
|
|
|
152
|
7 |
|
public function getName() |
153
|
|
|
{ |
154
|
7 |
|
return $this->name; |
155
|
|
|
} |
156
|
|
|
|
157
|
7 |
|
public function setName($name) |
158
|
|
|
{ |
159
|
7 |
|
$this->name = $name; |
160
|
7 |
|
} |
161
|
|
|
|
162
|
5 |
|
public function getAccountId() |
163
|
|
|
{ |
164
|
5 |
|
return $this->accountId; |
165
|
|
|
} |
166
|
|
|
|
167
|
7 |
|
public function setAccountId($accountId) |
168
|
|
|
{ |
169
|
7 |
|
$this->accountId = $accountId; |
170
|
7 |
|
} |
171
|
|
|
|
172
|
4 |
|
public function getConfidenceThreshold() |
173
|
|
|
{ |
174
|
4 |
|
return $this->confidenceThreshold; |
175
|
|
|
} |
176
|
|
|
|
177
|
3 |
|
public function setConfidenceThreshold($confidenceThreshold) |
178
|
|
|
{ |
179
|
3 |
|
$this->confidenceThreshold = $confidenceThreshold; |
180
|
3 |
|
} |
181
|
|
|
|
182
|
4 |
|
public function getDcpServiceId() |
183
|
|
|
{ |
184
|
4 |
|
return $this->dcpServiceId; |
185
|
|
|
} |
186
|
|
|
|
187
|
3 |
|
public function setDcpServiceId($dcpServiceId) |
188
|
|
|
{ |
189
|
3 |
|
$this->dcpServiceId = $dcpServiceId; |
190
|
3 |
|
} |
191
|
|
|
|
192
|
4 |
|
public function getPlatform() |
193
|
|
|
{ |
194
|
4 |
|
return $this->platform; |
195
|
|
|
} |
196
|
|
|
|
197
|
3 |
|
public function setPlatform($platform) |
198
|
|
|
{ |
199
|
3 |
|
$this->platform = $platform; |
200
|
3 |
|
} |
201
|
|
|
|
202
|
4 |
|
public function getStatus() |
203
|
|
|
{ |
204
|
4 |
|
return $this->status; |
205
|
|
|
} |
206
|
|
|
|
207
|
3 |
|
public function setStatus($status) |
208
|
|
|
{ |
209
|
3 |
|
$this->status = $status; |
210
|
3 |
|
} |
211
|
|
|
|
212
|
5 |
|
public function getWebSnippet() |
213
|
|
|
{ |
214
|
5 |
|
return $this->webSnippet; |
215
|
|
|
} |
216
|
|
|
|
217
|
7 |
|
public function setWebSnippet($webSnippet) |
218
|
|
|
{ |
219
|
7 |
|
$this->webSnippet = $webSnippet; |
220
|
7 |
|
} |
221
|
|
|
|
222
|
5 |
|
public function getCreated() |
223
|
|
|
{ |
224
|
5 |
|
return $this->created; |
225
|
|
|
} |
226
|
|
|
|
227
|
7 |
|
public function setCreated($created) |
228
|
|
|
{ |
229
|
7 |
|
$this->created = $created; |
230
|
7 |
|
} |
231
|
|
|
|
232
|
5 |
|
public function getId() |
233
|
|
|
{ |
234
|
5 |
|
return $this->id; |
235
|
|
|
} |
236
|
|
|
|
237
|
7 |
|
public function setId($id) |
238
|
|
|
{ |
239
|
7 |
|
$this->id = $id; |
240
|
7 |
|
} |
241
|
|
|
|
242
|
5 |
|
public function getIsClassic() |
243
|
|
|
{ |
244
|
5 |
|
return $this->isClassic; |
245
|
|
|
} |
246
|
|
|
|
247
|
6 |
|
public function setIsClassic($isClassic) |
248
|
|
|
{ |
249
|
6 |
|
$this->isClassic = $isClassic; |
250
|
6 |
|
} |
251
|
|
|
|
252
|
5 |
|
public function getLastModified() |
253
|
|
|
{ |
254
|
5 |
|
return $this->lastModified; |
255
|
|
|
} |
256
|
|
|
|
257
|
6 |
|
public function setLastModified($lastModified) |
258
|
|
|
{ |
259
|
6 |
|
$this->lastModified = $lastModified; |
260
|
6 |
|
} |
261
|
|
|
|
262
|
5 |
|
public function getSocketToken() |
263
|
|
|
{ |
264
|
5 |
|
return $this->socketToken; |
265
|
|
|
} |
266
|
|
|
|
267
|
6 |
|
public function setSocketToken($socketToken) |
268
|
|
|
{ |
269
|
6 |
|
$this->socketToken = $socketToken; |
270
|
6 |
|
} |
271
|
|
|
} |
272
|
|
|
|
273
|
|
|
|
274
|
|
|
|
275
|
|
|
|
According to the PSR-2, the body of a case statement must start on the line immediately following the case statement.
}
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.