1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Acquia\LiftClient\Entity; |
4
|
|
|
|
5
|
|
|
use Acquia\LiftClient\Exception\LiftSdkException; |
6
|
|
|
use Acquia\LiftClient\Utility\Utility; |
7
|
|
|
|
8
|
|
|
class Goal extends Entity |
9
|
|
|
{ |
10
|
|
|
/** |
11
|
|
|
* @param array $array |
12
|
|
|
*/ |
13
|
63 |
|
public function __construct(array $array = []) |
14
|
|
|
{ |
15
|
63 |
|
parent::__construct($array); |
16
|
63 |
|
} |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Sets the 'id' parameter. |
20
|
|
|
* |
21
|
|
|
* @param string $id |
22
|
|
|
* |
23
|
|
|
* @throws \Acquia\LiftClient\Exception\LiftSdkException |
24
|
|
|
* |
25
|
|
|
* @return \Acquia\LiftClient\Entity\Goal |
26
|
|
|
*/ |
27
|
15 |
|
public function setId($id) |
28
|
|
|
{ |
29
|
15 |
|
if (!is_string($id)) { |
30
|
3 |
|
throw new LiftSdkException('Argument must be an instance of string.'); |
31
|
|
|
} |
32
|
12 |
|
$this['id'] = $id; |
33
|
|
|
|
34
|
12 |
|
return $this; |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Gets the 'id' parameter. |
39
|
|
|
* |
40
|
|
|
* @return string The Identifier of the Goal |
41
|
|
|
*/ |
42
|
9 |
|
public function getId() |
43
|
|
|
{ |
44
|
9 |
|
return $this->getEntityValue('id', ''); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Sets the 'name' parameter. |
49
|
|
|
* |
50
|
|
|
* @param string $name |
51
|
|
|
* |
52
|
|
|
* @throws \Acquia\LiftClient\Exception\LiftSdkException |
53
|
|
|
* |
54
|
|
|
* @return \Acquia\LiftClient\Entity\Goal |
55
|
|
|
*/ |
56
|
15 |
|
public function setName($name) |
57
|
|
|
{ |
58
|
15 |
|
if (!is_string($name)) { |
59
|
3 |
|
throw new LiftSdkException('Argument must be an instance of string.'); |
60
|
|
|
} |
61
|
12 |
|
$this['name'] = $name; |
62
|
|
|
|
63
|
12 |
|
return $this; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* Gets the 'name' parameter. |
68
|
|
|
* |
69
|
|
|
* @return string The Name of the Goal |
70
|
|
|
*/ |
71
|
9 |
|
public function getName() |
72
|
|
|
{ |
73
|
9 |
|
return $this->getEntityValue('name', ''); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* Sets the 'description' parameter. |
78
|
|
|
* |
79
|
|
|
* @param string $description |
80
|
|
|
* |
81
|
|
|
* @throws \Acquia\LiftClient\Exception\LiftSdkException |
82
|
|
|
* |
83
|
|
|
* @return \Acquia\LiftClient\Entity\Goal |
84
|
|
|
*/ |
85
|
15 |
|
public function setDescription($description) |
86
|
|
|
{ |
87
|
15 |
|
if (!is_string($description)) { |
88
|
3 |
|
throw new LiftSdkException('Argument must be an instance of string.'); |
89
|
|
|
} |
90
|
12 |
|
$this['description'] = $description; |
91
|
|
|
|
92
|
12 |
|
return $this; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* Gets the 'description' parameter. |
97
|
|
|
* |
98
|
|
|
* @return string The Description of the Goal |
99
|
|
|
*/ |
100
|
9 |
|
public function getDescription() |
101
|
|
|
{ |
102
|
9 |
|
return $this->getEntityValue('description', ''); |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* Sets the 'rule_ids' parameter. |
107
|
|
|
* |
108
|
|
|
* @param array $ruleIds |
109
|
|
|
* |
110
|
|
|
* @throws \Acquia\LiftClient\Exception\LiftSdkException |
111
|
|
|
* |
112
|
|
|
* @return \Acquia\LiftClient\Entity\Goal |
113
|
|
|
*/ |
114
|
15 |
View Code Duplication |
public function setRuleIds(array $ruleIds) |
115
|
|
|
{ |
116
|
15 |
|
if (Utility::arrayDepth($ruleIds) > 1) { |
117
|
3 |
|
throw new LiftSdkException('Rule Ids argument is more than 1 level deep.'); |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
// Set only the array values to the rule_ids property. |
121
|
12 |
|
$this['rule_ids'] = array_values($ruleIds); |
122
|
|
|
|
123
|
12 |
|
return $this; |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* Gets the 'rule_ids' parameter. |
128
|
|
|
* |
129
|
|
|
* @return array The Rule Identifiers |
130
|
|
|
*/ |
131
|
9 |
|
public function getRuleIds() |
132
|
|
|
{ |
133
|
9 |
|
return $this->getEntityValue('rule_ids', []); |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* Sets the 'site_ids' parameter. |
138
|
|
|
* |
139
|
|
|
* @param array $siteIds |
140
|
|
|
* |
141
|
|
|
* @throws \Acquia\LiftClient\Exception\LiftSdkException |
142
|
|
|
* |
143
|
|
|
* @return \Acquia\LiftClient\Entity\Goal |
144
|
|
|
*/ |
145
|
15 |
View Code Duplication |
public function setSiteIds(array $siteIds) |
146
|
|
|
{ |
147
|
15 |
|
if (Utility::arrayDepth($siteIds) > 1) { |
148
|
3 |
|
throw new LiftSdkException('Site Ids argument is more than 1 level deep.'); |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
// Set only the array values to the site_ids property. |
152
|
12 |
|
$this['site_ids'] = array_values($siteIds); |
153
|
|
|
|
154
|
12 |
|
return $this; |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
/** |
158
|
|
|
* Gets the 'site_ids' parameter. |
159
|
|
|
* |
160
|
|
|
* @return array The Site Identifiers |
161
|
|
|
*/ |
162
|
9 |
|
public function getSiteIds() |
163
|
|
|
{ |
164
|
9 |
|
return $this->getEntityValue('site_ids', []); |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
/** |
168
|
|
|
* Sets the 'event_names' parameter. |
169
|
|
|
* |
170
|
|
|
* @param array $eventNames |
171
|
|
|
* |
172
|
|
|
* @throws \Acquia\LiftClient\Exception\LiftSdkException |
173
|
|
|
* |
174
|
|
|
* @return \Acquia\LiftClient\Entity\Goal |
175
|
|
|
*/ |
176
|
15 |
View Code Duplication |
public function setEventNames(array $eventNames) |
177
|
|
|
{ |
178
|
15 |
|
if (Utility::arrayDepth($eventNames) > 1) { |
179
|
3 |
|
throw new LiftSdkException('Event Names argument is more than 1 level deep.'); |
180
|
|
|
} |
181
|
|
|
|
182
|
|
|
// Set only the array values to the event_names property. |
183
|
12 |
|
$this['event_names'] = array_values($eventNames); |
184
|
|
|
|
185
|
12 |
|
return $this; |
186
|
|
|
} |
187
|
|
|
|
188
|
|
|
/** |
189
|
|
|
* Gets the 'rule_ids' parameter. |
190
|
|
|
* |
191
|
|
|
* @return array The Rule Identifiers |
192
|
|
|
*/ |
193
|
9 |
|
public function getEventNames() |
194
|
|
|
{ |
195
|
9 |
|
return $this->getEntityValue('event_names', []); |
196
|
|
|
} |
197
|
|
|
|
198
|
|
|
/** |
199
|
|
|
* Sets the 'global' parameter. |
200
|
|
|
* |
201
|
|
|
* @param bool $global |
202
|
|
|
* |
203
|
|
|
* @throws \Acquia\LiftClient\Exception\LiftSdkException |
204
|
|
|
* |
205
|
|
|
* @return \Acquia\LiftClient\Entity\Goal |
206
|
|
|
*/ |
207
|
6 |
|
public function setGlobal($global) |
208
|
|
|
{ |
209
|
6 |
|
if (!is_bool($global)) { |
210
|
3 |
|
throw new LiftSdkException('Argument must be an instance of boolean.'); |
211
|
|
|
} |
212
|
3 |
|
$this['global'] = $global; |
213
|
|
|
|
214
|
3 |
|
return $this; |
215
|
|
|
} |
216
|
|
|
|
217
|
|
|
/** |
218
|
|
|
* Gets the 'global' parameter. |
219
|
|
|
* |
220
|
|
|
* @return bool |
221
|
|
|
*/ |
222
|
9 |
|
public function getGlobal() |
223
|
|
|
{ |
224
|
9 |
|
return $this->getEntityValue('global', false); |
225
|
|
|
} |
226
|
|
|
|
227
|
|
|
/** |
228
|
|
|
* Sets the 'value' parameter. |
229
|
|
|
* |
230
|
|
|
* @param float|int $value |
231
|
|
|
* |
232
|
|
|
* @throws \Acquia\LiftClient\Exception\LiftSdkException |
233
|
|
|
* |
234
|
|
|
* @return \Acquia\LiftClient\Entity\Goal |
235
|
|
|
*/ |
236
|
6 |
|
public function setValue($value) |
237
|
|
|
{ |
238
|
6 |
|
if (!is_float($value) && !is_int($value)) { |
239
|
3 |
|
throw new LiftSdkException('Argument must be an instance of float or int.'); |
240
|
|
|
} |
241
|
3 |
|
$this['value'] = $value; |
242
|
|
|
|
243
|
3 |
|
return $this; |
244
|
|
|
} |
245
|
|
|
|
246
|
|
|
/** |
247
|
|
|
* Gets the 'value' parameter. |
248
|
|
|
* |
249
|
|
|
* @return float |
250
|
|
|
*/ |
251
|
9 |
|
public function getValue() |
252
|
|
|
{ |
253
|
9 |
|
return $this->getEntityValue('value', ''); |
254
|
|
|
} |
255
|
|
|
} |
256
|
|
|
|