Completed
Push — master ( 96059f...fe2237 )
by Oleg
06:07
created

ExperimentMetricResults   A

Complexity

Total Complexity 24

Size/Duplication

Total Lines 154
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 94.83%

Importance

Changes 0
Metric Value
dl 0
loc 154
ccs 55
cts 58
cp 0.9483
rs 10
c 0
b 0
f 0
wmc 24
lcom 1
cbo 1

16 Methods

Rating   Name   Duplication   Size   Complexity  
B __construct() 0 16 9
A toArray() 0 12 1
A getEvent() 0 4 1
A setEvent() 0 4 1
A getEventName() 0 4 1
A setEventName() 0 4 1
A getMeasure() 0 4 1
A setMeasure() 0 4 1
A getMetricId() 0 4 1
A setMetricId() 0 4 1
A getPriority() 0 4 1
A setPriority() 0 4 1
A getUnit() 0 4 1
A setUnit() 0 4 1
A getVariationResults() 0 4 1
A setVariationResults() 0 4 1
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;
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...
70 3
                case 'event_name': $this->setEventName($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...
71 3
                case 'measure': $this->setMeasure($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...
72 3
                case 'metric_id': $this->setMetricId($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...
73 3
                case 'priority': $this->setPriority($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...
74 3
                case 'unit': $this->setUnit($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...
75 3
                case 'variation_results': $this->setVariationResults($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...
76
                default:
77
                    throw new Exception('Unknown option found in the ExperimentMetricResults entity: ' . $name);
78
            }
79 3
        }
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 1
        );
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