1 | <?php |
||
14 | class Datapoint |
||
15 | { |
||
16 | /** |
||
17 | * The confidence interval measures the uncertainty around improvement. It |
||
18 | * starts out wide and shrinks as more data comes in. Significance means |
||
19 | * that the confidence interval is completely above or completely below 0. |
||
20 | * If the result is significant and positive, the confidence interval will |
||
21 | * be above 0. If the result is significant and negative, confidence interval |
||
22 | * will be below 0. If the result is inconclusive, confidence interval includes 0. |
||
23 | * @var array[number] |
||
24 | */ |
||
25 | private $confidenceInterval; |
||
26 | |||
27 | /** |
||
28 | * Indicates that this is the best performing variant for this metric. |
||
29 | * Also referred to as the 'Winner' |
||
30 | * @var boolean |
||
31 | */ |
||
32 | private $isMostConclusive; |
||
33 | |||
34 | /** |
||
35 | * Indicates if significance is above your confidence threshold |
||
36 | * @var boolean |
||
37 | */ |
||
38 | private $isSignificant; |
||
39 | |||
40 | /** |
||
41 | * The likelihood that the observed difference in conversion rate is not due to chance. |
||
42 | * @var number |
||
43 | */ |
||
44 | private $significance; |
||
45 | |||
46 | /** |
||
47 | * The relative improvement for this variant over the baseline variant. |
||
48 | * @var number |
||
49 | */ |
||
50 | private $value; |
||
51 | |||
52 | /** |
||
53 | * The number of estimated visitors remaining before result becomes statistically significant |
||
54 | * @var integer |
||
55 | */ |
||
56 | private $visitorsRemaining; |
||
57 | /** |
||
58 | * Constructor. |
||
59 | */ |
||
60 | 3 | public function __construct($options = array()) |
|
61 | { |
||
62 | 3 | foreach ($options as $name=>$value) { |
|
63 | switch ($name) { |
||
64 | 3 | case 'confidence_interval': $this->setConfidenceInterval($value); break; |
|
65 | 3 | case 'is_most_conclusive': $this->setIsMostConclusive($value); break; |
|
66 | 3 | case 'is_significant': $this->setIsSignificant($value); break; |
|
67 | 3 | case 'significance': $this->setSignificance($value); break; |
|
68 | 3 | case 'value': $this->setValue($value); break; |
|
69 | 3 | case 'visitors_remaining': $this->setVisitorsRemaining($value); break; |
|
70 | default: |
||
71 | 3 | throw new Exception('Unknown option: ' . $name); |
|
72 | } |
||
73 | } |
||
74 | 3 | } |
|
75 | |||
76 | /** |
||
77 | * Returns this object as array. |
||
78 | */ |
||
79 | 1 | public function toArray() |
|
80 | { |
||
81 | $options = array( |
||
82 | 1 | 'confidence_interval' => $this->getConfidenceInterval(), |
|
83 | 1 | 'is_most_conclusive' => $this->getIsMostConclusive(), |
|
84 | 1 | 'is_significant' => $this->getIsSignificant(), |
|
85 | 1 | 'significance' => $this->getSignificance(), |
|
86 | 1 | 'value' => $this->getValue(), |
|
87 | 1 | 'visitors_remaining' => $this->getVisitorsRemaining(), |
|
88 | ); |
||
89 | |||
90 | // Remove options with empty values |
||
91 | 1 | $cleanedOptions = array(); |
|
92 | 1 | foreach ($options as $name=>$value) { |
|
93 | 1 | if ($value!==null) |
|
94 | 1 | $cleanedOptions[$name] = $value; |
|
95 | } |
||
96 | |||
97 | 1 | return $cleanedOptions; |
|
98 | } |
||
99 | |||
100 | 1 | public function getConfidenceInterval() |
|
104 | |||
105 | 3 | public function setConfidenceInterval($confidenceInterval) |
|
109 | |||
110 | 1 | public function getIsMostConclusive() |
|
114 | |||
115 | 3 | public function setIsMostConclusive($isMostConclusive) |
|
119 | |||
120 | 1 | public function getIsSignificant() |
|
124 | |||
125 | 3 | public function setIsSignificant($isSignificant) |
|
129 | |||
130 | 1 | public function getSignificance() |
|
134 | |||
135 | 3 | public function setSignificance($significance) |
|
139 | |||
140 | 1 | public function getValue() |
|
144 | |||
145 | 3 | public function setValue($value) |
|
149 | |||
150 | 1 | public function getVisitorsRemaining() |
|
154 | |||
155 | 3 | public function setVisitorsRemaining($visitorsRemaining) |
|
159 | } |
||
160 | |||
161 | |||
168 |
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.