1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @author Oleg Krivtsov <[email protected]> |
4
|
|
|
* @date 12 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
|
|
|
* Optimizely experiment metric results. |
13
|
|
|
*/ |
14
|
|
|
class ExperimentMetricResults |
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* |
18
|
|
|
* @var string |
19
|
|
|
*/ |
20
|
|
|
private $event; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* |
24
|
|
|
* @var string |
25
|
|
|
*/ |
26
|
|
|
private $eventName; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Conversions indicate the total number of visitors or sessions where the |
30
|
|
|
* event happened. Impressions indicate the total number of times the event |
31
|
|
|
* happened (possibly multiple per visitor or session). Revenue indicates |
32
|
|
|
* the sum of all revenue sent from all events in the Experiment. |
33
|
|
|
* Can be 'conversions', 'impressions' or 'revenue'. |
34
|
|
|
* @var string |
35
|
|
|
*/ |
36
|
|
|
private $measure; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* |
40
|
|
|
* @var string |
41
|
|
|
*/ |
42
|
|
|
private $metricId; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* |
46
|
|
|
* @var integer |
47
|
|
|
*/ |
48
|
|
|
private $priority; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Can be 'session', 'visitor' or 'event' |
52
|
|
|
* @var string |
53
|
|
|
*/ |
54
|
|
|
private $unit; |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* A map of results for each Variation in the Experiment keyed by Variation ID |
58
|
|
|
* @var array[VariantResults] |
59
|
|
|
*/ |
60
|
|
|
private $variationResults; |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Constructor. |
64
|
|
|
*/ |
65
|
3 |
|
public function __construct($options = array()) |
66
|
|
|
{ |
67
|
3 |
|
foreach ($options as $name=>$value) { |
68
|
|
|
switch ($name) { |
69
|
3 |
|
case 'event': $this->setEvent($value); break; |
|
|
|
|
70
|
3 |
|
case 'event_name': $this->setEventName($value); break; |
|
|
|
|
71
|
3 |
|
case 'measure': $this->setMeasure($value); break; |
|
|
|
|
72
|
3 |
|
case 'metric_id': $this->setMetricId($value); break; |
|
|
|
|
73
|
3 |
|
case 'priority': $this->setPriority($value); break; |
|
|
|
|
74
|
3 |
|
case 'unit': $this->setUnit($value); break; |
|
|
|
|
75
|
3 |
|
case 'variation_results': $this->setVariationResults($value); break; |
|
|
|
|
76
|
|
|
default: |
77
|
3 |
|
throw new Exception('Unknown option: ' . $name); |
78
|
|
|
} |
79
|
|
|
} |
80
|
3 |
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* Returns this object as array. |
84
|
|
|
*/ |
85
|
1 |
|
public function toArray() |
86
|
|
|
{ |
87
|
|
|
return array( |
88
|
1 |
|
'event' => $this->getEvent(), |
89
|
1 |
|
'event_name' => $this->getEventName(), |
90
|
1 |
|
'measure' => $this->getMeasure(), |
91
|
1 |
|
'metric_id' => $this->getMetricId(), |
92
|
1 |
|
'priority' => $this->getPriority(), |
93
|
1 |
|
'unit' => $this->getUnit(), |
94
|
1 |
|
'variation_results' => $this->getVariationResults(), |
95
|
|
|
); |
96
|
|
|
} |
97
|
|
|
|
98
|
1 |
|
public function getEvent() |
99
|
|
|
{ |
100
|
1 |
|
return $this->event; |
101
|
|
|
} |
102
|
|
|
|
103
|
3 |
|
public function setEvent($event) |
104
|
|
|
{ |
105
|
3 |
|
$this->event = $event; |
106
|
3 |
|
} |
107
|
|
|
|
108
|
1 |
|
public function getEventName() |
109
|
|
|
{ |
110
|
1 |
|
return $this->eventName; |
111
|
|
|
} |
112
|
|
|
|
113
|
3 |
|
public function setEventName($eventName) |
114
|
|
|
{ |
115
|
3 |
|
$this->eventName = $eventName; |
116
|
3 |
|
} |
117
|
|
|
|
118
|
1 |
|
public function getMeasure() |
119
|
|
|
{ |
120
|
1 |
|
return $this->measure; |
121
|
|
|
} |
122
|
|
|
|
123
|
3 |
|
public function setMeasure($measure) |
124
|
|
|
{ |
125
|
3 |
|
$this->measure = $measure; |
126
|
3 |
|
} |
127
|
|
|
|
128
|
1 |
|
public function getMetricId() |
129
|
|
|
{ |
130
|
1 |
|
return $this->metricId; |
131
|
|
|
} |
132
|
|
|
|
133
|
3 |
|
public function setMetricId($metricId) |
134
|
|
|
{ |
135
|
3 |
|
$this->metricId = $metricId; |
136
|
3 |
|
} |
137
|
|
|
|
138
|
1 |
|
public function getPriority() |
139
|
|
|
{ |
140
|
1 |
|
return $this->priority; |
141
|
|
|
} |
142
|
|
|
|
143
|
3 |
|
public function setPriority($priority) |
144
|
|
|
{ |
145
|
3 |
|
$this->priority = $priority; |
146
|
3 |
|
} |
147
|
|
|
|
148
|
1 |
|
public function getUnit() |
149
|
|
|
{ |
150
|
1 |
|
return $this->unit; |
151
|
|
|
} |
152
|
|
|
|
153
|
3 |
|
public function setUnit($unit) |
154
|
|
|
{ |
155
|
3 |
|
$this->unit = $unit; |
156
|
3 |
|
} |
157
|
|
|
|
158
|
1 |
|
public function getVariationResults() |
159
|
|
|
{ |
160
|
1 |
|
return $this->variationResults; |
161
|
|
|
} |
162
|
|
|
|
163
|
3 |
|
public function setVariationResults($variationResults) |
164
|
|
|
{ |
165
|
3 |
|
$this->variationResults = $variationResults; |
166
|
3 |
|
} |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
|
170
|
|
|
|
171
|
|
|
|
172
|
|
|
|
173
|
|
|
|
174
|
|
|
|
175
|
|
|
|
176
|
|
|
|
177
|
|
|
|
178
|
|
|
|
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.