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