|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @author Oleg Krivtsov <[email protected]> |
|
4
|
|
|
* @date 07 October 2016 |
|
5
|
|
|
* @copyright (c) 2016, Web Marketing ROI |
|
6
|
|
|
*/ |
|
7
|
|
|
namespace WebMarketingROI\OptimizelyPHP\Resource\v2; |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* An Optimizely audience. |
|
11
|
|
|
*/ |
|
12
|
|
|
class Audience |
|
13
|
|
|
{ |
|
14
|
|
|
/** |
|
15
|
|
|
* The project the Audience was created in |
|
16
|
|
|
* @var integer |
|
17
|
|
|
*/ |
|
18
|
|
|
private $projectId; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Whether the Audience has been archived |
|
22
|
|
|
* @var boolean |
|
23
|
|
|
*/ |
|
24
|
|
|
private $archived; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* A string defining the targeting rules for an audience. |
|
28
|
|
|
* @var string |
|
29
|
|
|
*/ |
|
30
|
|
|
private $conditions; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* A short description of the Audience |
|
34
|
|
|
* @var string |
|
35
|
|
|
*/ |
|
36
|
|
|
private $description; |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* The name of the Audience |
|
40
|
|
|
* @var string |
|
41
|
|
|
*/ |
|
42
|
|
|
private $name; |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* True if the audiences is available for segmentation on the results page (Platinum only). |
|
46
|
|
|
* @var boolean |
|
47
|
|
|
*/ |
|
48
|
|
|
private $segmentation; |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* The time the Audience was initially created |
|
52
|
|
|
* @var string |
|
53
|
|
|
*/ |
|
54
|
|
|
private $created; |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* The unique identifier for the Audience. |
|
58
|
|
|
* @var integer |
|
59
|
|
|
*/ |
|
60
|
|
|
private $id; |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* The last time the Audience was modified |
|
64
|
|
|
* @var string |
|
65
|
|
|
*/ |
|
66
|
|
|
private $lastModified; |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* Constructor. |
|
70
|
|
|
*/ |
|
71
|
7 |
|
public function __construct($options = array()) |
|
72
|
|
|
{ |
|
73
|
7 |
|
foreach ($options as $name=>$value) { |
|
74
|
|
|
switch ($name) { |
|
75
|
6 |
|
case 'project_id': $this->setProjectId($value); break; |
|
|
|
|
|
|
76
|
6 |
|
case 'archived': $this->setArchived($value); break; |
|
|
|
|
|
|
77
|
6 |
|
case 'conditions': $this->setConditions($value); break; |
|
|
|
|
|
|
78
|
6 |
|
case 'description': $this->setDescription($value); break; |
|
|
|
|
|
|
79
|
6 |
|
case 'name': $this->setName($value); break; |
|
|
|
|
|
|
80
|
6 |
|
case 'segmentation': $this->setSegmentation($value); break; |
|
|
|
|
|
|
81
|
4 |
|
case 'created': $this->setCreated($value); break; |
|
|
|
|
|
|
82
|
4 |
|
case 'id': $this->setId($value); break; |
|
|
|
|
|
|
83
|
4 |
|
case 'last_modified': $this->setLastModified($value); break; |
|
|
|
|
|
|
84
|
|
|
default: |
|
85
|
|
|
throw new \Exception('Unknown option: ' . $name); |
|
86
|
|
|
} |
|
87
|
7 |
|
} |
|
88
|
7 |
|
} |
|
89
|
|
|
|
|
90
|
|
|
/** |
|
91
|
|
|
* Returns this object as array. |
|
92
|
|
|
*/ |
|
93
|
3 |
|
public function toArray() |
|
94
|
|
|
{ |
|
95
|
|
|
$options = array( |
|
96
|
3 |
|
'project_id' => $this->projectId, |
|
97
|
3 |
|
'archived' => $this->archived, |
|
98
|
3 |
|
'conditions' => $this->conditions, |
|
99
|
3 |
|
'description' => $this->description, |
|
100
|
3 |
|
'name' => $this->name, |
|
101
|
3 |
|
'segmentation' => $this->segmentation, |
|
102
|
3 |
|
'created' => $this->created, |
|
103
|
3 |
|
'id' => $this->id, |
|
104
|
3 |
|
'last_modified' => $this->lastModified |
|
105
|
3 |
|
); |
|
106
|
|
|
|
|
107
|
|
|
// Remove options with empty values |
|
108
|
3 |
|
$cleanedOptions = array(); |
|
109
|
3 |
|
foreach ($options as $name=>$value) { |
|
110
|
3 |
|
if ($value!==null) |
|
111
|
3 |
|
$cleanedOptions[$name] = $value; |
|
112
|
3 |
|
} |
|
113
|
|
|
|
|
114
|
3 |
|
return $cleanedOptions; |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
2 |
|
public function getProjectId() |
|
118
|
|
|
{ |
|
119
|
2 |
|
return $this->projectId; |
|
120
|
|
|
} |
|
121
|
|
|
|
|
122
|
7 |
|
public function setProjectId($projectId) |
|
123
|
|
|
{ |
|
124
|
7 |
|
$this->projectId = $projectId; |
|
125
|
7 |
|
} |
|
126
|
|
|
|
|
127
|
2 |
|
public function getArchived() |
|
128
|
|
|
{ |
|
129
|
2 |
|
return $this->archived; |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
7 |
|
public function setArchived($archived) |
|
133
|
|
|
{ |
|
134
|
7 |
|
$this->archived = $archived; |
|
135
|
7 |
|
} |
|
136
|
|
|
|
|
137
|
2 |
|
public function getConditions() |
|
138
|
|
|
{ |
|
139
|
2 |
|
return $this->conditions; |
|
140
|
|
|
} |
|
141
|
|
|
|
|
142
|
7 |
|
public function setConditions($conditions) |
|
143
|
|
|
{ |
|
144
|
7 |
|
$this->conditions = $conditions; |
|
145
|
7 |
|
} |
|
146
|
|
|
|
|
147
|
2 |
|
public function getDescription() |
|
148
|
|
|
{ |
|
149
|
2 |
|
return $this->description; |
|
150
|
|
|
} |
|
151
|
|
|
|
|
152
|
7 |
|
public function setDescription($description) |
|
153
|
|
|
{ |
|
154
|
7 |
|
$this->description = $description; |
|
155
|
7 |
|
} |
|
156
|
|
|
|
|
157
|
6 |
|
public function getName() |
|
158
|
|
|
{ |
|
159
|
6 |
|
return $this->name; |
|
160
|
|
|
} |
|
161
|
|
|
|
|
162
|
7 |
|
public function setName($name) |
|
163
|
|
|
{ |
|
164
|
7 |
|
$this->name = $name; |
|
165
|
7 |
|
} |
|
166
|
|
|
|
|
167
|
2 |
|
public function getSegmentation() |
|
168
|
|
|
{ |
|
169
|
2 |
|
return $this->segmentation; |
|
170
|
|
|
} |
|
171
|
|
|
|
|
172
|
7 |
|
public function setSegmentation($segmentation) |
|
173
|
|
|
{ |
|
174
|
7 |
|
$this->segmentation = $segmentation; |
|
175
|
7 |
|
} |
|
176
|
|
|
|
|
177
|
1 |
|
public function getCreated() |
|
178
|
|
|
{ |
|
179
|
1 |
|
return $this->created; |
|
180
|
|
|
} |
|
181
|
|
|
|
|
182
|
5 |
|
public function setCreated($created) |
|
183
|
|
|
{ |
|
184
|
5 |
|
$this->created = $created; |
|
185
|
5 |
|
} |
|
186
|
|
|
|
|
187
|
1 |
|
public function getId() |
|
188
|
|
|
{ |
|
189
|
1 |
|
return $this->id; |
|
190
|
|
|
} |
|
191
|
|
|
|
|
192
|
5 |
|
public function setId($id) |
|
193
|
|
|
{ |
|
194
|
5 |
|
$this->id = $id; |
|
195
|
5 |
|
} |
|
196
|
|
|
|
|
197
|
1 |
|
public function getLastModified() |
|
198
|
|
|
{ |
|
199
|
1 |
|
return $this->lastModified; |
|
200
|
|
|
} |
|
201
|
|
|
|
|
202
|
5 |
|
public function setLastModified($lastModified) |
|
203
|
|
|
{ |
|
204
|
5 |
|
$this->lastModified = $lastModified; |
|
205
|
5 |
|
} |
|
206
|
|
|
} |
|
207
|
|
|
|
|
208
|
|
|
|
|
209
|
|
|
|
|
210
|
|
|
|
|
211
|
|
|
|
|
212
|
|
|
|
|
213
|
|
|
|
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.