Completed
Push — develop ( 6fdb58...dee5cf )
by Oleg
04:27 queued 01:45
created

Datapoint   A

Complexity

Total Complexity 23

Size/Duplication

Total Lines 146
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 146
ccs 52
cts 52
cp 1
rs 10
c 0
b 0
f 0
wmc 23
lcom 1
cbo 0

14 Methods

Rating   Name   Duplication   Size   Complexity  
A getConfidenceInterval() 0 4 1
A setConfidenceInterval() 0 4 1
A getIsMostConclusive() 0 4 1
A setIsMostConclusive() 0 4 1
A getIsSignificant() 0 4 1
A setIsSignificant() 0 4 1
A getSignificance() 0 4 1
A setSignificance() 0 4 1
A getValue() 0 4 1
A setValue() 0 4 1
A getVisitorsRemaining() 0 4 1
A setVisitorsRemaining() 0 4 1
B __construct() 0 15 8
A toArray() 0 20 3
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 datapoint.
11
 */
12
class Datapoint
13
{
14
    /**
15
     * The confidence interval measures the uncertainty around improvement. It 
16
     * starts out wide and shrinks as more data comes in. Significance means 
17
     * that the confidence interval is completely above or completely below 0. 
18
     * If the result is significant and positive, the confidence interval will 
19
     * be above 0. If the result is significant and negative, confidence interval 
20
     * will be below 0. If the result is inconclusive, confidence interval includes 0.
21
     * @var array[number]
22
     */
23
    private $confidenceInterval;
24
    
25
    /**
26
     * Indicates that this is the best performing variant for this metric. 
27
     * Also referred to as the 'Winner'
28
     * @var boolean 
29
     */
30
    private $isMostConclusive;
31
    
32
    /**
33
     * Indicates if significance is above your confidence threshold
34
     * @var boolean
35
     */
36
    private $isSignificant;
37
    
38
    /**
39
     * The likelihood that the observed difference in conversion rate is not due to chance.
40
     * @var number 
41
     */
42
    private $significance;
43
    
44
    /**
45
     * The relative improvement for this variant over the baseline variant.
46
     * @var number
47
     */
48
    private $value;
49
    
50
    /**
51
     * The number of estimated visitors remaining before result becomes statistically significant
52
     * @var integer 
53
     */
54
    private $visitorsRemaining;
55
    /**
56
     * Constructor.
57
     */
58 3
    public function __construct($options = array())
59
    {
60 3
        foreach ($options as $name=>$value) {
61
            switch ($name) {                
62 3
                case 'confidence_interval': $this->setConfidenceInterval($value); break;
0 ignored issues
show
Coding Style introduced by
The case body in a switch statement must start on the line following the statement.

According to the PSR-2, the body of a case statement must start on the line immediately following the case statement.

switch ($expr) {
case "A":
    doSomething(); //right
    break;
case "B":

    doSomethingElse(); //wrong
    break;

}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
Coding Style introduced by
Terminating statement must be on a line by itself

As per the PSR-2 coding standard, the break (or other terminating) statement must be on a line of its own.

switch ($expr) {
     case "A":
         doSomething();
         break; //wrong
     case "B":
         doSomething();
         break; //right
     case "C:":
         doSomething();
         return true; //right
 }

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
63 3
                case 'is_most_conclusive': $this->setIsMostConclusive($value); break;
0 ignored issues
show
Coding Style introduced by
The case body in a switch statement must start on the line following the statement.

According to the PSR-2, the body of a case statement must start on the line immediately following the case statement.

switch ($expr) {
case "A":
    doSomething(); //right
    break;
case "B":

    doSomethingElse(); //wrong
    break;

}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
Coding Style introduced by
Terminating statement must be on a line by itself

As per the PSR-2 coding standard, the break (or other terminating) statement must be on a line of its own.

switch ($expr) {
     case "A":
         doSomething();
         break; //wrong
     case "B":
         doSomething();
         break; //right
     case "C:":
         doSomething();
         return true; //right
 }

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
64 3
                case 'is_significant': $this->setIsSignificant($value); break;
0 ignored issues
show
Coding Style introduced by
The case body in a switch statement must start on the line following the statement.

According to the PSR-2, the body of a case statement must start on the line immediately following the case statement.

switch ($expr) {
case "A":
    doSomething(); //right
    break;
case "B":

    doSomethingElse(); //wrong
    break;

}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
Coding Style introduced by
Terminating statement must be on a line by itself

As per the PSR-2 coding standard, the break (or other terminating) statement must be on a line of its own.

switch ($expr) {
     case "A":
         doSomething();
         break; //wrong
     case "B":
         doSomething();
         break; //right
     case "C:":
         doSomething();
         return true; //right
 }

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
65 3
                case 'significance': $this->setSignificance($value); break;
0 ignored issues
show
Coding Style introduced by
The case body in a switch statement must start on the line following the statement.

According to the PSR-2, the body of a case statement must start on the line immediately following the case statement.

switch ($expr) {
case "A":
    doSomething(); //right
    break;
case "B":

    doSomethingElse(); //wrong
    break;

}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
Coding Style introduced by
Terminating statement must be on a line by itself

As per the PSR-2 coding standard, the break (or other terminating) statement must be on a line of its own.

switch ($expr) {
     case "A":
         doSomething();
         break; //wrong
     case "B":
         doSomething();
         break; //right
     case "C:":
         doSomething();
         return true; //right
 }

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
66 3
                case 'value': $this->setValue($value); break;
0 ignored issues
show
Coding Style introduced by
The case body in a switch statement must start on the line following the statement.

According to the PSR-2, the body of a case statement must start on the line immediately following the case statement.

switch ($expr) {
case "A":
    doSomething(); //right
    break;
case "B":

    doSomethingElse(); //wrong
    break;

}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
Coding Style introduced by
Terminating statement must be on a line by itself

As per the PSR-2 coding standard, the break (or other terminating) statement must be on a line of its own.

switch ($expr) {
     case "A":
         doSomething();
         break; //wrong
     case "B":
         doSomething();
         break; //right
     case "C:":
         doSomething();
         return true; //right
 }

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
67 3
                case 'visitors_remaining': $this->setVisitorsRemaining($value); break;
0 ignored issues
show
Coding Style introduced by
The case body in a switch statement must start on the line following the statement.

According to the PSR-2, the body of a case statement must start on the line immediately following the case statement.

switch ($expr) {
case "A":
    doSomething(); //right
    break;
case "B":

    doSomethingElse(); //wrong
    break;

}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
Coding Style introduced by
Terminating statement must be on a line by itself

As per the PSR-2 coding standard, the break (or other terminating) statement must be on a line of its own.

switch ($expr) {
     case "A":
         doSomething();
         break; //wrong
     case "B":
         doSomething();
         break; //right
     case "C:":
         doSomething();
         return true; //right
 }

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
68
                default:
69 3
                    throw new \Exception('Unknown option: ' . $name);
70
            }
71
        }
72 3
    }
73
    
74
    /**
75
     * Returns this object as array.
76
     */
77 1
    public function toArray()
78
    {
79
        $options = array(
80 1
            'confidence_interval' => $this->getConfidenceInterval(),
81 1
            'is_most_conclusive' => $this->getIsMostConclusive(),
82 1
            'is_significant' => $this->getIsSignificant(),
83 1
            'significance' => $this->getSignificance(),
84 1
            'value' => $this->getValue(),            
85 1
            'visitors_remaining' => $this->getVisitorsRemaining(),            
86
        );
87
        
88
        // Remove options with empty values
89 1
        $cleanedOptions = array();
90 1
        foreach ($options as $name=>$value) {
91 1
            if ($value!==null)
92 1
                $cleanedOptions[$name] = $value;
93
        }
94
        
95 1
        return $cleanedOptions;
96
    }
97
    
98 1
    public function getConfidenceInterval()
99
    {
100 1
        return $this->confidenceInterval;
101
    }
102
    
103 3
    public function setConfidenceInterval($confidenceInterval)
104
    {
105 3
        $this->confidenceInterval = $confidenceInterval;
106 3
    }
107
    
108 1
    public function getIsMostConclusive()
109
    {
110 1
        return $this->isMostConclusive;
111
    }
112
    
113 3
    public function setIsMostConclusive($isMostConclusive)
114
    {
115 3
        $this->isMostConclusive = $isMostConclusive;
116 3
    }
117
    
118 1
    public function getIsSignificant()
119
    {
120 1
        return $this->isSignificant;
121
    }
122
    
123 3
    public function setIsSignificant($isSignificant)
124
    {
125 3
        $this->isSignificant = $isSignificant;
126 3
    }
127
    
128 1
    public function getSignificance()
129
    {
130 1
        return $this->significance;
131
    }
132
    
133 3
    public function setSignificance($significance)
134
    {
135 3
        $this->significance = $significance;
136 3
    }
137
    
138 1
    public function getValue()
139
    {
140 1
        return $this->value;
141
    }
142
    
143 3
    public function setValue($value)
144
    {
145 3
        $this->value = $value;
146 3
    }
147
    
148 1
    public function getVisitorsRemaining()
149
    {
150 1
        return $this->visitorsRemaining;
151
    }
152
    
153 3
    public function setVisitorsRemaining($visitorsRemaining)
154
    {
155 3
        $this->visitorsRemaining = $visitorsRemaining;
156 3
    }
157
}
158
159
160
161
162
163
164
165
166