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