Completed
Push — master ( 761b5c...f27f71 )
by Oleg
03:34
created

Experiment::setLatest()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 4
ccs 0
cts 3
cp 0
crap 2
rs 10
1
<?php
2
/**
3
 * @author Oleg Krivtsov <[email protected]>
4
 * @date 05 October 2016
5
 * @copyright (c) 2016, Web Marketing ROI
6
 */
7
namespace WebMarketingROI\OptimizelyPHP\Resource\v2;
8
9
use WebMarketingROI\OptimizelyPHP\Exception;
10
use WebMarketingROI\OptimizelyPHP\Resource\v2\Schedule;
11
use WebMarketingROI\OptimizelyPHP\Resource\v2\Variation;
12
use WebMarketingROI\OptimizelyPHP\Resource\v2\Change;
13
use WebMarketingROI\OptimizelyPHP\Resource\v2\Metric;
14
15
/**
16
 * An Optimizely experiment.
17
 */
18
class Experiment
19
{
20
    /**
21
     * The project the Experiment is in
22
     * @var integer
23
     */
24
    private $projectId;
25
    
26
    /**
27
     * List of IDs of all audiences the Experiment is targeted at
28
     * @var array[integer] 
29
     */
30
    private $audienceIds;
31
    
32
    /**
33
     * The ID for the Campaign that the Experiment is in
34
     * @var integer 
35
     */
36
    private $campaignId;
37
    
38
    /**
39
     * Experiment-level changes that will run before all Variations. Typically 
40
     * this is custom CSS or custom JavaScript.
41
     * @var array[Change] 
42
     */
43
    private $changes;
44
    
45
    /**
46
     * The time the experiment was initially created
47
     * @var string 
48
     */
49
    private $created;
50
    
51
    /**
52
     * The description or hypothesis for an Experiment
53
     * @var string 
54
     */
55
    private $description;
56
    
57
    /**
58
     * Percentage expressed as a number from 0-10000 to hold back from being 
59
     * included in the experiment
60
     * @var integer 
61
     */
62
    private $holdback;
63
    
64
    /**
65
     * Unique string identifier for this experiment within the project.
66
     * @var string
67
     */
68
    private $key;
69
    
70
    /**
71
     * The last time the experiment was modified
72
     * @var string 
73
     */
74
    private $lastModified;
75
    
76
    /**
77
     * An ordered list of metrics to track for the experiment
78
     * @var array[Metric] 
79
     */
80
    private $metrics;
81
    
82
    /**
83
     * Name of the Experiment
84
     * @var string 
85
     */
86
    private $name;
87
    
88
    /**
89
     * The last time the experiment was modified
90
     * @var Schedule 
91
     */
92
    private $schedule;
93
    
94
    /**
95
     * Current state of the experiment. Can be 'active', 'paused' or 'archived'.
96
     * @var string 
97
     */
98
    private $status;
99
    
100
    /**
101
     * A list of Variations that each define an experience to show in the context 
102
     * of the Experiment for the purpose of comparison against each other
103
     * @var array[Variation]
104
     */
105
    private $variations = array();
106
    
107
    /**
108
     * The unique identifier for the Experiment
109
     * @var integer 
110
     */
111
    private $id;
112
    
113
    /**
114
     * Whether or not the Experiment is a classic Experiment
115
     * @var boolean
116
     */
117
    private $isClassic;
118
    
119
    /**
120
     * Indicates whether this is a standalone a/b experiment or an experience within a personalization campaign
121
     * Can be a/b or personalization
122
     * @var string
123
     */
124
    private $type;
125
    
126
    /**
127
     * The audiences that should see this experiment. If the field is null or 
128
     * omitted, the experiment will target everyone. Multiple audiences can be 
129
     * combined with "and" or "or" using the same structure as audience conditions
130
     * @var string 
131
     */
132
    private $audienceConditions;
133
    
134
    /**
135
     * Traffic allocation policy across variations in this experiment
136
     * @var string 
137
     */
138
    private $allocationPolicy;
139
    
140
    /**
141
     * The first time the Experiment was activated
142
     * @var type 
143
     */
144
    private $earliest;
145
    
146
    /**
147
     * A list of Page IDs used in the Experiment. url_targeting or page_ids, but not both.
148
     */
149
    private $pageIds;
150
    
151
    /**
152
     * The last time the Experiment was activated (not present if it is still activated)
153
     * @var type 
154
     */
155
    private $latest;
156
    
157
    /**
158
     * Constructor.
159
     */
160 7
    public function __construct($options = array())
161
    {
162 7
        foreach ($options as $name=>$value) {
163
            switch ($name) {
164 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...
165 6
                case 'audience_ids': $this->setAudienceIds($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...
166 6
                case 'campaign_id': $this->setCampaignId($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...
167 6 View Code Duplication
                case 'changes': {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
Coding Style introduced by
case statements should be defined using a colon.

As per the PSR-2 coding standard, case statements should not be wrapped in curly braces. There is no need for braces, since each case is terminated by the next break.

There is also the option to use a semicolon instead of a colon, this is discouraged because many programmers do not even know it works and the colon is universal between programming languages.

switch ($expr) {
    case "A": { //wrong
        doSomething();
        break;
    }
    case "B"; //wrong
        doSomething();
        break;
    case "C": //right
        doSomething();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
168 6
                    $changes = array();
169 6
                    foreach ($value as $changeInfo) {
170 6
                        $changes[] = new Change($changeInfo);
171
                    }
172 6
                    $this->setChanges($changes); 
173 6
                    break;
174
                }
175 6
                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...
176 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...
177 6
                case 'holdback': $this->setHoldback($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...
178 6
                case 'key': $this->setKey($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...
179 6
                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...
180 6
                case 'metrics': {
0 ignored issues
show
Coding Style introduced by
case statements should be defined using a colon.

As per the PSR-2 coding standard, case statements should not be wrapped in curly braces. There is no need for braces, since each case is terminated by the next break.

There is also the option to use a semicolon instead of a colon, this is discouraged because many programmers do not even know it works and the colon is universal between programming languages.

switch ($expr) {
    case "A": { //wrong
        doSomething();
        break;
    }
    case "B"; //wrong
        doSomething();
        break;
    case "C": //right
        doSomething();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
181 6
                    $metrics = array();
182 6
                    foreach ($value as $metricInfo) {
183 6
                        $metrics[] = new Metric($metricInfo);
184
                    }
185 6
                    $this->setMetrics($metrics); 
186 6
                    break;    
187
                }
188 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...
189 6
                case 'schedule': $this->setSchedule(new Schedule($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...
190 6
                case 'status': $this->setStatus($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...
191 6 View Code Duplication
                case 'variations': {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
Coding Style introduced by
case statements should be defined using a colon.

As per the PSR-2 coding standard, case statements should not be wrapped in curly braces. There is no need for braces, since each case is terminated by the next break.

There is also the option to use a semicolon instead of a colon, this is discouraged because many programmers do not even know it works and the colon is universal between programming languages.

switch ($expr) {
    case "A": { //wrong
        doSomething();
        break;
    }
    case "B"; //wrong
        doSomething();
        break;
    case "C": //right
        doSomething();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
192 6
                    $variations = array();
193 6
                    foreach ($value as $variationInfo) {
194 6
                        $variations[] = new Variation($variationInfo);
195
                    }
196 6
                    $this->setVariations($variations); 
197 6
                    break;
198
                }
199 5
                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...
200 5
                case 'is_classic': $this->setIsClassic($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...
201 1
                case 'type': $this->setType($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...
202 1
                case 'audience_conditions': $this->setAudienceConditions($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...
203
                case 'allocation_policy': $this->setAllocationPolicy($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...
204
                case 'earliest': $this->setEarliest($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...
205
                case 'page_ids': $this->setPageIds($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...
206
                case 'latest': $this->setLatest($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...
207
                default:
208 6
                    throw new Exception('Unknown option found in the Experiment entity: ' . $name);
209
            }
210
        }
211 7
    }
212
    
213
    /**
214
     * Returns this object as array.
215
     */
216 3
    public function toArray()
217
    {
218
        $options = array(
219 3
            'project_id' => $this->getProjectId(),
220 3
            'audience_ids' => $this->getAudienceIds(),
221 3
            'campaign_id' => $this->getCampaignId(),
222 3
            'created' => $this->getCreated(),
223 3
            'description' => $this->getDescription(),
224 3
            'holdback' => $this->getHoldback(),
225 3
            'key' => $this->getKey(),
226 3
            'last_modified' => $this->getLastModified(),
227 3
            'name' => $this->getName(),
228 3
            'schedule' => $this->getSchedule()?$this->getSchedule()->toArray():null,
229 3
            'status' => $this->getStatus(),            
230 3
            'id' => $this->getId(),
231 3
            'is_classic' => $this->getIsClassic(),
232 3
            'type' => $this->getType(),
233 3
            'audience_conditions' => $this->getAudienceConditions(),  
234 3
            'allocation_policy' => $this->getAllocationPolicy(),
235 3
            'earliest' => $this->getEarliest(),
236 3
            'page_ids' => $this->getPageIds(),
237 3
            'latest' => $this->getLatest(),
238
        );
239
        
240 3
        if ($this->getChanges()) {
241
            
242 3
            $options['changes'] = array();
243
            
244 3
            foreach ($this->getChanges() as $change) {
245 3
                $options['changes'][] = $change->toArray();
246
            }
247
        }
248
        
249 3
        if ($this->getMetrics()) {
250
            
251 3
            $options['metrics'] = array();
252
            
253 3
            foreach ($this->getMetrics() as $metric) {
254 3
                $options['metrics'][] = $metric->toArray();
255
            }
256
        }
257
        
258 3
        if ($this->getVariations()) {
259
            
260 3
            $options['variations'] = array();
261
            
262 3
            foreach ($this->getVariations() as $variation) {
263 3
                $options['variations'][] = $variation->toArray();
264
            }
265
        }
266
        
267
        // Remove options with empty values
268 3
        $cleanedOptions = array();
269 3
        foreach ($options as $name=>$value) {
270 3
            if ($value!==null)
271 3
                $cleanedOptions[$name] = $value;
272
        }
273
        
274 3
        return $cleanedOptions;
275
    }
276
    
277 5
    public function getProjectId()
278
    {
279 5
        return $this->projectId;
280
    }
281
    
282 7
    public function setProjectId($projectId)
283
    {
284 7
        $this->projectId = $projectId;
285 7
    }
286
    
287 4
    public function getAudienceIds()
288
    {
289 4
        return $this->audienceIds;
290
    }
291
    
292 7
    public function setAudienceIds($audienceIds)
293
    {
294 7
        $this->audienceIds = $audienceIds;
295 7
    }
296
    
297 4
    public function getCampaignId()
298
    {
299 4
        return $this->campaignId;
300
    }
301
    
302 7
    public function setCampaignId($campaignId)
303
    {
304 7
        $this->campaignId = $campaignId;
305 7
    }
306
    
307 4
    public function getChanges()
308
    {
309 4
        return $this->changes;
310
    }
311
    
312 7
    public function setChanges($changes)
313
    {
314 7
        $this->changes = $changes;
315 7
    }
316
    
317 4
    public function getCreated()
318
    {
319 4
        return $this->created;
320
    }
321
    
322 5
    public function setCreated($created)
323
    {
324 5
        $this->created = $created;
325 5
    }
326
    
327 4
    public function getDescription()
328
    {
329 4
        return $this->description;
330
    }
331
    
332 7
    public function setDescription($description)
333
    {
334 7
        $this->description = $description;
335 7
    }
336
    
337 4
    public function getHoldback()
338
    {
339 4
        return $this->holdback;
340
    }
341
    
342 7
    public function setHoldback($holdback)
343
    {
344 7
        $this->holdback = $holdback;
345 7
    }
346
    
347 4
    public function getKey()
348
    {
349 4
        return $this->key;
350
    }
351
    
352 7
    public function setKey($key)
353
    {
354 7
        $this->key = $key;
355 7
    }
356
    
357 4
    public function getLastModified()
358
    {
359 4
        return $this->lastModified;
360
    }
361
    
362 5
    public function setLastModified($lastModified)
363
    {
364 5
        $this->lastModified = $lastModified;
365 5
    }
366
    
367 4
    public function getMetrics()
368
    {
369 4
        return $this->metrics;
370
    }
371
    
372 7
    public function setMetrics($metrics)
373
    {
374 7
        $this->metrics = $metrics;
375 7
    }
376
    
377 7
    public function getName()
378
    {
379 7
        return $this->name;
380
    }
381
    
382 7
    public function setName($name)
383
    {
384 7
        $this->name = $name;
385 7
    }
386
    
387 4
    public function getSchedule()
388
    {
389 4
        return $this->schedule;
390
    }
391
    
392 7
    public function setSchedule($schedule)
393
    {
394 7
        $this->schedule = $schedule;
395 7
    }
396
    
397 4
    public function getStatus()
398
    {
399 4
        return $this->status;
400
    }
401
    
402 7
    public function setStatus($status)
403
    {
404 7
        $this->status = $status;
405 7
    }
406
    
407 4
    public function getVariations()
408
    {
409 4
        return $this->variations;
410
    }
411
    
412 7
    public function setVariations($variations)
413
    {
414 7
        $this->variations = $variations;
415 7
    }
416
    
417 4
    public function getId()
418
    {
419 4
        return $this->id;
420
    }
421
    
422 5
    public function setId($id)
423
    {
424 5
        $this->id = $id;
425 5
    }
426
    
427 4
    public function getIsClassic()
428
    {
429 4
        return $this->isClassic;
430
    }
431
    
432 5
    public function setIsClassic($isClassic)
433
    {
434 5
        $this->isClassic = $isClassic;
435 5
    }
436
    
437 3
    public function getType()
438
    {
439 3
        return $this->type;
440
    }
441
    
442 2
    public function setType($type)
443
    {
444 2
        $this->type = $type;
445 2
    }
446
    
447 3
    public function getAudienceConditions()
448
    {
449 3
        return $this->audienceConditions;
450
    }
451
    
452 2
    public function setAudienceConditions($audienceConditions)
453
    {
454 2
        $this->audienceConditions = $audienceConditions;
455 2
    }
456
    
457
    public function getConfig()
458
    {
459
        return $this->config;
0 ignored issues
show
Bug introduced by
The property config does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
460
    }
461
    
462
    public function setConfig($config)
463
    {
464
        $this->config = $config;
465
    }
466
    
467 3
    public function getAllocationPolicy()
468
    {
469 3
        return $this->allocationPolicy;
470
    }
471
    
472
    public function setAllocationPolicy($allocationPolicy)
473
    {
474
        $this->allocationPolicy = $allocationPolicy;
475
    }
476
    
477 3
    public function getEarliest()
478
    {
479 3
        return $this->earliest;
480
    }
481
    
482
    public function setEarliest($earliest)
483
    {
484
        $this->earliest = $earliest;
485
    }
486
    
487 3
    public function getPageIds()
488
    {
489 3
        return $this->pageIds;
490
    }
491
    
492
    public function setPageIds($pageIds)
493
    {
494
        $this->pageIds = $pageIds;
495
    }
496
    
497 3
    public function getLatest()
498
    {
499 3
        return $this->latest;
500
    }
501
    
502
    public function setLatest($latest)
503
    {
504
        $this->latest = $latest;
505
    }
506
}
507
508