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

VariationReach   A

Complexity

Total Complexity 17

Size/Duplication

Total Lines 105
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 105
ccs 38
cts 38
cp 1
rs 10
c 0
b 0
f 0
wmc 17
lcom 1
cbo 0

10 Methods

Rating   Name   Duplication   Size   Complexity  
A getCount() 0 4 1
A setCount() 0 4 1
A getName() 0 4 1
A setName() 0 4 1
A getVariationId() 0 4 1
A setVariationId() 0 4 1
A getVariationReach() 0 4 1
A setVariationReach() 0 4 1
B __construct() 0 13 6
A toArray() 0 18 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 variation reach.
11
 */
12
class VariationReach
13
{
14
    /**
15
     * Total number of visitors exposed to this particular variation
16
     * @var integer
17
     */
18
    private $count;
19
    
20
    /**
21
     * The name of the variation
22
     * @var string
23
     */
24
    private $name;
25
    
26
    /**
27
     * The unique identifier for the variation
28
     * @var string
29
     */
30
    private $variationId;
31
    
32
    /**
33
     *
34
     * @var number
35
     */
36
    private $variationReach;
37
    
38
    /**
39
     * Constructor.
40
     */
41 3
    public function __construct($options = array())
42
    {
43 3
        foreach ($options as $name=>$value) {
44
            switch ($name) {                
45 3
                case 'count': $this->setCount($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...
46 3
                case 'name': $this->setName($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...
47 3
                case 'variation_id': $this->setVariationId($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...
48 3
                case 'variation_reach': $this->setVariationReach($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...
49
                default:
50 3
                    throw new \Exception('Unknown option: ' . $name);
51
            }
52
        }
53 3
    }
54
    
55
    /**
56
     * Returns this object as array.
57
     */
58 1
    public function toArray()
59
    {
60
        $options = array(
61 1
            'count' => $this->getCount(),
62 1
            'name' => $this->getName(),
63 1
            'variation_id' => $this->getVariationId(),
64 1
            'variation_reach' => $this->getVariationReach(),            
65
        );
66
        
67
        // Remove options with empty values
68 1
        $cleanedOptions = array();
69 1
        foreach ($options as $name=>$value) {
70 1
            if ($value!==null)
71 1
                $cleanedOptions[$name] = $value;
72
        }
73
        
74 1
        return $cleanedOptions;
75
    }
76
    
77 1
    public function getCount()
78
    {
79 1
        return $this->count;
80
    }
81
    
82 3
    public function setCount($count)
83
    {
84 3
        $this->count = $count;
85 3
    }
86
    
87 1
    public function getName()
88
    {
89 1
        return $this->name;
90
    }
91
    
92 3
    public function setName($name)
93
    {
94 3
        $this->name = $name;
95 3
    }
96
    
97 1
    public function getVariationId()
98
    {
99 1
        return $this->variationId;
100
    }
101
    
102 3
    public function setVariationId($variationId)
103
    {
104 3
        $this->variationId = $variationId;
105 3
    }
106
    
107 1
    public function getVariationReach()
108
    {
109 1
        return $this->variationReach;
110
    }
111
    
112 3
    public function setVariationReach($variationReach)
113
    {
114 3
        $this->variationReach = $variationReach;
115 3
    }
116
}
117
118
119
120
121
122
123
124
125
126
127
128