Completed
Push — master ( 0ca99d...7c70a3 )
by Oleg
02:52
created

Audience   A

Complexity

Total Complexity 32

Size/Duplication

Total Lines 195
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 96.15%

Importance

Changes 0
Metric Value
dl 0
loc 195
ccs 75
cts 78
cp 0.9615
rs 9.6
c 0
b 0
f 0
wmc 32
lcom 1
cbo 0

20 Methods

Rating   Name   Duplication   Size   Complexity  
B __construct() 0 18 11
A toArray() 0 23 3
A getProjectId() 0 4 1
A setProjectId() 0 4 1
A getArchived() 0 4 1
A setArchived() 0 4 1
A getConditions() 0 4 1
A setConditions() 0 4 1
A getDescription() 0 4 1
A setDescription() 0 4 1
A getName() 0 4 1
A setName() 0 4 1
A getSegmentation() 0 4 1
A setSegmentation() 0 4 1
A getCreated() 0 4 1
A setCreated() 0 4 1
A getId() 0 4 1
A setId() 0 4 1
A getLastModified() 0 4 1
A setLastModified() 0 4 1
1
<?php
2
/**
3
 * @author Oleg Krivtsov <[email protected]>
4
 * @date 07 October 2016
5
 * @copyright (c) 2016, Web Marketing ROI
6
 */
7
namespace WebMarketingROI\OptimizelyPHP\Resource\v2;
8
9
/**
10
 * An Optimizely audience.
11
 */
12
class Audience
13
{
14
    /**
15
     * The project the Audience was created in
16
     * @var integer 
17
     */
18
    private $projectId;
19
    
20
    /**
21
     * Whether the Audience has been archived
22
     * @var boolean 
23
     */
24
    private $archived;
25
    
26
    /**
27
     * A string defining the targeting rules for an audience.
28
     * @var string 
29
     */
30
    private $conditions;
31
    
32
    /**
33
     * A short description of the Audience
34
     * @var string 
35
     */
36
    private $description;
37
    
38
    /**
39
     * The name of the Audience
40
     * @var string 
41
     */
42
    private $name;
43
    
44
    /**
45
     * True if the audiences is available for segmentation on the results page (Platinum only).
46
     * @var boolean 
47
     */
48
    private $segmentation;
49
    
50
    /**
51
     * The time the Audience was initially created
52
     * @var string 
53
     */
54
    private $created;
55
    
56
    /**
57
     * The unique identifier for the Audience.
58
     * @var integer 
59
     */
60
    private $id;
61
    
62
    /**
63
     * The last time the Audience was modified
64
     * @var string 
65
     */
66
    private $lastModified;
67
    
68
    /**
69
     * Constructor.
70
     */
71 7
    public function __construct($options = array())
72
    {
73 7
        foreach ($options as $name=>$value) {
74
            switch ($name) {                
75 6
                case 'project_id': $this->setProjectId($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 6
                case 'archived': $this->setArchived($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...
77 6
                case 'conditions': $this->setConditions($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...
78 6
                case 'description': $this->setDescription($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...
79 6
                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...
80 6
                case 'segmentation': $this->setSegmentation($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...
81 4
                case 'created': $this->setCreated($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...
82 4
                case 'id': $this->setId($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...
83 4
                case 'last_modified': $this->setLastModified($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...
84
                default:
85
                    throw new \Exception('Unknown option: ' . $name);
86
            }
87 7
        }
88 7
    }
89
    
90
    /**
91
     * Returns this object as array.
92
     */
93 3
    public function toArray()
94
    {
95
        $options = array(
96 3
            'project_id' => $this->projectId,
97 3
            'archived' => $this->archived,
98 3
            'conditions' => $this->conditions,
99 3
            'description' => $this->description,
100 3
            'name' => $this->name,
101 3
            'segmentation' => $this->segmentation,
102 3
            'created' => $this->created,
103 3
            'id' => $this->id,
104 3
            'last_modified' => $this->lastModified
105 3
        );
106
        
107
        // Remove options with empty values
108 3
        $cleanedOptions = array();
109 3
        foreach ($options as $name=>$value) {
110 3
            if ($value!==null)
111 3
                $cleanedOptions[$name] = $value;
112 3
        }
113
        
114 3
        return $cleanedOptions;
115
    }
116
    
117 2
    public function getProjectId()
118
    {
119 2
        return $this->projectId;
120
    }
121
    
122 7
    public function setProjectId($projectId)
123
    {
124 7
        $this->projectId = $projectId;
125 7
    }
126
    
127 2
    public function getArchived()
128
    {
129 2
        return $this->archived;
130
    }
131
    
132 7
    public function setArchived($archived)
133
    {
134 7
        $this->archived = $archived;
135 7
    }
136
    
137 2
    public function getConditions()
138
    {
139 2
        return $this->conditions;
140
    }
141
    
142 7
    public function setConditions($conditions)
143
    {
144 7
        $this->conditions = $conditions;
145 7
    }
146
    
147 2
    public function getDescription()
148
    {
149 2
        return $this->description;
150
    }
151
    
152 7
    public function setDescription($description)
153
    {
154 7
        $this->description = $description;
155 7
    }
156
        
157 6
    public function getName()
158
    {
159 6
        return $this->name;
160
    }
161
    
162 7
    public function setName($name)
163
    {
164 7
        $this->name = $name;
165 7
    }
166
        
167 2
    public function getSegmentation()
168
    {
169 2
        return $this->segmentation;
170
    }
171
    
172 7
    public function setSegmentation($segmentation)
173
    {
174 7
        $this->segmentation = $segmentation;
175 7
    }
176
    
177 1
    public function getCreated()
178
    {
179 1
        return $this->created;
180
    }
181
    
182 5
    public function setCreated($created)
183
    {
184 5
        $this->created = $created;
185 5
    }
186
    
187 1
    public function getId()
188
    {
189 1
        return $this->id;
190
    }
191
    
192 5
    public function setId($id)
193
    {
194 5
        $this->id = $id;
195 5
    }
196
    
197 1
    public function getLastModified()
198
    {
199 1
        return $this->lastModified;
200
    }
201
    
202 5
    public function setLastModified($lastModified)
203
    {
204 5
        $this->lastModified = $lastModified;
205 5
    }
206
}
207
208
209
210
211
212
213