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

ExperimentMetricResults   A

Complexity

Total Complexity 24

Size/Duplication

Total Lines 154
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

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

16 Methods

Rating   Name   Duplication   Size   Complexity  
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
B __construct() 0 16 9
A toArray() 0 12 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
/**
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;
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 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...
69 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...
70 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...
71 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...
72 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...
73 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...
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