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

Schedule   A

Complexity

Total Complexity 14

Size/Duplication

Total Lines 87
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 87
ccs 31
cts 31
cp 1
rs 10
c 0
b 0
f 0
wmc 14
lcom 1
cbo 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A getStartTime() 0 4 1
A setStartTime() 0 4 1
A getStopTime() 0 4 1
A setStopTime() 0 4 1
A getTimezone() 0 4 1
A setTimezone() 0 4 1
B __construct() 0 12 5
A toArray() 0 17 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 schedule.
11
 */
12
class Schedule
13
{
14
    /**
15
     * The start time for the Experiment
16
     * @var string 
17
     */
18
    private $startTime;
19
    
20
    /**
21
     * The stop time for the Experiment
22
     * @var string 
23
     */
24
    private $stopTime;
25
    
26
    /**
27
     * The time zone to use for Experiment start/stop times
28
     * @var string 
29
     */
30
    private $timezone;
31
    
32
    /**
33
     * Constructor.
34
     */
35 7
    public function __construct($options = array())
36
    {
37 7
        foreach ($options as $name=>$value) {
38
            switch ($name) {                
39 6
                case 'start_time': $this->setStartTime($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...
40 6
                case 'stop_time': $this->setStopTime($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...
41 6
                case 'time_zone': $this->setTimezone($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...
42
                default:
43 6
                    throw new \Exception('Unknown option: ' . $name);
44
            }
45
        }
46 7
    }
47
    
48
    /**
49
     * Returns this object as array.
50
     */
51 3
    public function toArray()
52
    {
53
        $options = array(
54 3
            'start_time' => $this->getStartTime(),
55 3
            'stop_time' => $this->getStopTime(),
56 3
            'time_zone' => $this->getTimezone(),            
57
        );
58
        
59
        // Remove options with empty values
60 3
        $cleanedOptions = array();
61 3
        foreach ($options as $name=>$value) {
62 3
            if ($value!==null)
63 3
                $cleanedOptions[$name] = $value;
64
        }
65
        
66 3
        return $cleanedOptions;
67
    }
68
    
69 4
    public function getStartTime()
70
    {
71 4
        return $this->startTime;
72
    }
73
    
74 7
    public function setStartTime($startTime)
75
    {
76 7
        $this->startTime = $startTime;
77 7
    }
78
    
79 3
    public function getStopTime()
80
    {
81 3
        return $this->stopTime;
82
    }
83
    
84 7
    public function setStopTime($stopTime)
85
    {
86 7
        $this->stopTime = $stopTime;
87 7
    }
88
    
89 4
    public function getTimezone()
90
    {
91 4
        return $this->timezone;
92
    }
93
    
94 6
    public function setTimezone($timezone)
95
    {
96 6
        $this->timezone = $timezone;
97 6
    }
98
}
99
100
101
102
103
104
105
106