|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @author Oleg Krivtsov <[email protected]> |
|
4
|
|
|
* @date 05 October 2016 |
|
5
|
|
|
* @copyright (c) 2016, Web Marketing ROI |
|
6
|
|
|
*/ |
|
7
|
|
|
namespace WebMarketingROI\OptimizelyPHP\Resource\v2; |
|
8
|
|
|
|
|
9
|
|
|
use WebMarketingROI\OptimizelyPHP\Exception; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* An Optimizely experiment. |
|
13
|
|
|
*/ |
|
14
|
|
|
class UrlTargeting |
|
15
|
|
|
{ |
|
16
|
|
|
/** |
|
17
|
|
|
* Conditions to activate the experiment; our knowledge base article on |
|
18
|
|
|
* Activation Types is the best guide for how to set up this data. |
|
19
|
|
|
* @var type |
|
20
|
|
|
*/ |
|
21
|
|
|
private $conditions; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* URL to load in the editor for this page |
|
25
|
|
|
* @var type |
|
26
|
|
|
*/ |
|
27
|
|
|
private $editUrl; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* Stringified Javascript function that determines when the Page is activated. |
|
31
|
|
|
* Only required when activation_type is 'polling' or 'callback'. |
|
32
|
|
|
* @var type |
|
33
|
|
|
*/ |
|
34
|
|
|
private $activationCode; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* How this page is activated. See the full documentation on the Page object. |
|
38
|
|
|
* @var type |
|
39
|
|
|
*/ |
|
40
|
|
|
private $activationType; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Unique string identifier for this Page within the Project |
|
44
|
|
|
* @var type |
|
45
|
|
|
*/ |
|
46
|
|
|
private $key; |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* The unique identifier of the Page that represents the experiment or campaign's URL Targeting. |
|
50
|
|
|
* @var type |
|
51
|
|
|
*/ |
|
52
|
|
|
private $pageId; |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* Constructor. |
|
56
|
|
|
*/ |
|
57
|
|
|
public function __construct($options = array()) |
|
58
|
|
|
{ |
|
59
|
|
|
foreach ($options as $name=>$value) { |
|
60
|
|
|
switch ($name) { |
|
61
|
|
|
case 'conditions': $this->setConditions($value); break; |
|
|
|
|
|
|
62
|
|
|
case 'edit_url': $this->setEditUrl($value); break; |
|
|
|
|
|
|
63
|
|
|
case 'activation_code': $this->setActivationCode($value); break; |
|
|
|
|
|
|
64
|
|
|
case 'activation_type': $this->setActivationType($value); break; |
|
|
|
|
|
|
65
|
|
|
case 'key': $this->setKey($value); break; |
|
|
|
|
|
|
66
|
|
|
case 'page_id': $this->setPageId($value); break; |
|
|
|
|
|
|
67
|
|
|
|
|
68
|
|
|
default: |
|
69
|
|
|
throw new Exception('Unknown option found in the UrlTargeting entity: ' . $name); |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* Returns this object as array. |
|
76
|
|
|
*/ |
|
77
|
|
|
public function toArray() |
|
78
|
|
|
{ |
|
79
|
|
|
$options = array( |
|
|
|
|
|
|
80
|
|
|
'conditions' => $this->getConditions(), |
|
81
|
|
|
'edit_url' => $this->getEditUrl(), |
|
82
|
|
|
'activation_code' => $this->getActivationCode(), |
|
83
|
|
|
'activation_type' => $this->getActivationType(), |
|
84
|
|
|
'key' => $this->getKey(), |
|
85
|
|
|
'page_id' => $this->getPageId(), |
|
86
|
|
|
); |
|
87
|
|
|
|
|
88
|
|
|
return $cleanedOptions; |
|
|
|
|
|
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
public function getConditions() |
|
92
|
|
|
{ |
|
93
|
|
|
return $this->conditions; |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
public function setConditions($conditions) |
|
97
|
|
|
{ |
|
98
|
|
|
$this->conditions = $conditions; |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
public function getEditUrl() |
|
102
|
|
|
{ |
|
103
|
|
|
return $this->editUrl; |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
public function setEditUrl($editUrl) |
|
107
|
|
|
{ |
|
108
|
|
|
$this->editUrl = $editUrl; |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
public function getActivationCode() |
|
112
|
|
|
{ |
|
113
|
|
|
return $this->activationCode; |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
public function setActivationCode($activationCode) |
|
117
|
|
|
{ |
|
118
|
|
|
$this->activationCode = $activationCode; |
|
119
|
|
|
} |
|
120
|
|
|
|
|
121
|
|
|
public function getActivationType() |
|
122
|
|
|
{ |
|
123
|
|
|
return $this->activationType; |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
|
|
public function setActivationType($activationType) |
|
127
|
|
|
{ |
|
128
|
|
|
$this->activationType = $activationType; |
|
129
|
|
|
} |
|
130
|
|
|
|
|
131
|
|
|
public function getKey() |
|
132
|
|
|
{ |
|
133
|
|
|
return $this->key; |
|
134
|
|
|
} |
|
135
|
|
|
|
|
136
|
|
|
public function setKey($key) |
|
137
|
|
|
{ |
|
138
|
|
|
$this->key = $key; |
|
139
|
|
|
} |
|
140
|
|
|
|
|
141
|
|
|
public function getPageId() |
|
142
|
|
|
{ |
|
143
|
|
|
return $this->pageId; |
|
144
|
|
|
} |
|
145
|
|
|
|
|
146
|
|
|
public function setPageId($pageId) |
|
147
|
|
|
{ |
|
148
|
|
|
$this->pageId = $pageId; |
|
149
|
|
|
} |
|
150
|
|
|
} |
|
151
|
|
|
|
|
152
|
|
|
|
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.