@@ -16,14 +16,14 @@ discard block |
||
16 | 16 | use WebMarketingROI\OptimizelyPHP\Exception; |
17 | 17 | |
18 | 18 | // Init class autloading. |
19 | -include dirname(__FILE__) . '/../../vendor/autoload.php'; |
|
19 | +include dirname(__FILE__).'/../../vendor/autoload.php'; |
|
20 | 20 | |
21 | 21 | // Include Utils.php - a file containing helper functions |
22 | -include dirname(__FILE__) . '/../Utils.php'; |
|
22 | +include dirname(__FILE__).'/../Utils.php'; |
|
23 | 23 | |
24 | 24 | // Read project ID from command line. |
25 | -if ($argc!=2) { |
|
26 | - die('Expected 1 command-line argument, while got ' . $argc-1); |
|
25 | +if ($argc != 2) { |
|
26 | + die('Expected 1 command-line argument, while got '.$argc - 1); |
|
27 | 27 | } |
28 | 28 | $projectId = $argv[1]; |
29 | 29 | |
@@ -47,20 +47,20 @@ discard block |
||
47 | 47 | $experiments = $result->getPayload(); |
48 | 48 | |
49 | 49 | foreach ($experiments as $experiment) { |
50 | - echo "Name: " . $experiment->getName() . "\n"; |
|
51 | - echo "Description: " . $experiment->getDescription() . "\n"; |
|
52 | - echo "Status: " . $experiment->getStatus() . "\n"; |
|
53 | - echo "Created: " . $experiment->getCreated() . "\n"; |
|
50 | + echo "Name: ".$experiment->getName()."\n"; |
|
51 | + echo "Description: ".$experiment->getDescription()."\n"; |
|
52 | + echo "Status: ".$experiment->getStatus()."\n"; |
|
53 | + echo "Created: ".$experiment->getCreated()."\n"; |
|
54 | 54 | |
55 | 55 | echo "\n"; |
56 | 56 | } |
57 | 57 | |
58 | 58 | // Determine if there are more projects. |
59 | - if ($result->getNextPage()==null) |
|
59 | + if ($result->getNextPage() == null) |
|
60 | 60 | break; |
61 | 61 | |
62 | 62 | // Increment page counter. |
63 | - $page ++; |
|
63 | + $page++; |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | } catch (Exception $e) { |
@@ -74,6 +74,6 @@ discard block |
||
74 | 74 | |
75 | 75 | // Save access token for later use |
76 | 76 | $accessToken = $optimizelyClient->getAccessToken(); |
77 | -file_put_contents(dirname(__FILE__) . '/../access_token.json', json_encode($accessToken)); |
|
77 | +file_put_contents(dirname(__FILE__).'/../access_token.json', json_encode($accessToken)); |
|
78 | 78 | |
79 | 79 | echo "Done!\n"; |
@@ -55,8 +55,9 @@ |
||
55 | 55 | } |
56 | 56 | |
57 | 57 | // Determine if there are more projects. |
58 | - if ($result->getNextPage()==null) |
|
59 | - break; |
|
58 | + if ($result->getNextPage()==null) { |
|
59 | + break; |
|
60 | + } |
|
60 | 61 | |
61 | 62 | // Increment page counter. |
62 | 63 | $page ++; |
@@ -95,7 +95,7 @@ |
||
95 | 95 | /** |
96 | 96 | * Get campaign results |
97 | 97 | * @param integer $campaignId The id for the campaign you want results for |
98 | - * @param string $starTime The earliest time to count events in results. Defaults to the time that the campaign was first activated. |
|
98 | + * @param string $startTime The earliest time to count events in results. Defaults to the time that the campaign was first activated. |
|
99 | 99 | * @param string $endTime The latest time to count events in results. Defaults to the time the campaign was last active or the current time if the campaign is still running. |
100 | 100 | * @return Result |
101 | 101 | * @throws Exception |
@@ -37,17 +37,17 @@ discard block |
||
37 | 37 | * @return Result |
38 | 38 | * @throws Exception |
39 | 39 | */ |
40 | - public function listAll($projectId, $page=1, $perPage=25) |
|
40 | + public function listAll($projectId, $page = 1, $perPage = 25) |
|
41 | 41 | { |
42 | - if ($projectId<0) { |
|
42 | + if ($projectId < 0) { |
|
43 | 43 | throw new Exception("Expected positive integer project ID"); |
44 | 44 | } |
45 | 45 | |
46 | - if ($page<0) { |
|
46 | + if ($page < 0) { |
|
47 | 47 | throw new Exception('Invalid page number passed'); |
48 | 48 | } |
49 | 49 | |
50 | - if ($perPage<0 || $perPage>100) { |
|
50 | + if ($perPage < 0 || $perPage > 100) { |
|
51 | 51 | throw new Exception('Invalid page size passed'); |
52 | 52 | } |
53 | 53 | |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | Exception::CODE_INVALID_ARG); |
104 | 104 | } |
105 | 105 | |
106 | - if ($campaignId<0) { |
|
106 | + if ($campaignId < 0) { |
|
107 | 107 | throw new Exception("Expected positive integer campaign ID", |
108 | 108 | Exception::CODE_INVALID_ARG); |
109 | 109 | } |
@@ -35,13 +35,13 @@ discard block |
||
35 | 35 | * @return Result |
36 | 36 | * @throws Exception |
37 | 37 | */ |
38 | - public function listAll($page=1, $perPage=25) |
|
38 | + public function listAll($page = 1, $perPage = 25) |
|
39 | 39 | { |
40 | - if ($page<0) { |
|
40 | + if ($page < 0) { |
|
41 | 41 | throw new Exception('Invalid page number passed'); |
42 | 42 | } |
43 | 43 | |
44 | - if ($perPage<0 || $perPage>100) { |
|
44 | + if ($perPage < 0 || $perPage > 100) { |
|
45 | 45 | throw new Exception('Invalid page size passed'); |
46 | 46 | } |
47 | 47 | |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | */ |
70 | 70 | public function get($projectId) |
71 | 71 | { |
72 | - $projectId = (string)$projectId; |
|
72 | + $projectId = (string) $projectId; |
|
73 | 73 | |
74 | 74 | if (!preg_match('/^\d+$/', $projectId)) { |
75 | 75 | throw new Exception("A positive integer project ID expected, while got $projectId"); |
@@ -114,13 +114,13 @@ discard block |
||
114 | 114 | */ |
115 | 115 | public function update($projectId, $project) |
116 | 116 | { |
117 | - $projectId = (string)$projectId; |
|
117 | + $projectId = (string) $projectId; |
|
118 | 118 | |
119 | 119 | if (!preg_match('/\d+/', $projectId)) { |
120 | 120 | throw new Exception("A positive integer project ID expected, while got $projectId"); |
121 | 121 | } |
122 | 122 | |
123 | - if ($projectId<0) { |
|
123 | + if ($projectId < 0) { |
|
124 | 124 | throw new Exception("A positive project ID expected"); |
125 | 125 | } |
126 | 126 |
@@ -91,8 +91,9 @@ |
||
91 | 91 | // Remove options with empty values |
92 | 92 | $cleanedOptions = array(); |
93 | 93 | foreach ($options as $name=>$value) { |
94 | - if ($value!==null) |
|
95 | - $cleanedOptions[$name] = $value; |
|
94 | + if ($value!==null) { |
|
95 | + $cleanedOptions[$name] = $value; |
|
96 | + } |
|
96 | 97 | } |
97 | 98 | |
98 | 99 | return $cleanedOptions; |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | case 'value': $this->setValue($value); break; |
69 | 69 | case 'visitors_remaining': $this->setVisitorsRemaining($value); break; |
70 | 70 | default: |
71 | - throw new Exception('Unknown option found in the Datapoint entity: ' . $name); |
|
71 | + throw new Exception('Unknown option found in the Datapoint entity: '.$name); |
|
72 | 72 | } |
73 | 73 | } |
74 | 74 | } |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | // Remove options with empty values |
91 | 91 | $cleanedOptions = array(); |
92 | 92 | foreach ($options as $name=>$value) { |
93 | - if ($value!==null) |
|
93 | + if ($value !== null) |
|
94 | 94 | $cleanedOptions[$name] = $value; |
95 | 95 | } |
96 | 96 |
@@ -91,8 +91,9 @@ |
||
91 | 91 | // Remove options with empty values |
92 | 92 | $cleanedOptions = array(); |
93 | 93 | foreach ($options as $name=>$value) { |
94 | - if ($value!==null) |
|
95 | - $cleanedOptions[$name] = $value; |
|
94 | + if ($value!==null) { |
|
95 | + $cleanedOptions[$name] = $value; |
|
96 | + } |
|
96 | 97 | } |
97 | 98 | |
98 | 99 | return $cleanedOptions; |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | case 'page_id': $this->setPageId($value); break; |
50 | 50 | case 'share_link': $this->setShareLink($value); break; |
51 | 51 | default: |
52 | - throw new Exception('Unknown option found in the Action entity: ' . $name); |
|
52 | + throw new Exception('Unknown option found in the Action entity: '.$name); |
|
53 | 53 | } |
54 | 54 | } |
55 | 55 | } |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | // Remove options with empty values |
73 | 73 | $cleanedOptions = array(); |
74 | 74 | foreach ($options as $name=>$value) { |
75 | - if ($value!==null) |
|
75 | + if ($value !== null) |
|
76 | 76 | $cleanedOptions[$name] = $value; |
77 | 77 | } |
78 | 78 |
@@ -91,8 +91,9 @@ |
||
91 | 91 | // Remove options with empty values |
92 | 92 | $cleanedOptions = array(); |
93 | 93 | foreach ($options as $name=>$value) { |
94 | - if ($value!==null) |
|
95 | - $cleanedOptions[$name] = $value; |
|
94 | + if ($value!==null) { |
|
95 | + $cleanedOptions[$name] = $value; |
|
96 | + } |
|
96 | 97 | } |
97 | 98 | |
98 | 99 | return $cleanedOptions; |
@@ -63,9 +63,9 @@ discard block |
||
63 | 63 | case 'aggregator': $this->setAggregator($value); break; |
64 | 64 | case 'field': $this->setField($value); break; |
65 | 65 | case 'scope': $this->setScope($value); break; |
66 | - case 'winning_direction' : $this->setWinningDirection($value); break; |
|
66 | + case 'winning_direction' : $this->setWinningDirection($value); break; |
|
67 | 67 | default: |
68 | - throw new Exception('Unknown option found in the Metric entity: ' . $name); |
|
68 | + throw new Exception('Unknown option found in the Metric entity: '.$name); |
|
69 | 69 | } |
70 | 70 | } |
71 | 71 | } |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | // Remove options with empty values |
87 | 87 | $cleanedOptions = array(); |
88 | 88 | foreach ($options as $name=>$value) { |
89 | - if ($value!==null) |
|
89 | + if ($value !== null) |
|
90 | 90 | $cleanedOptions[$name] = $value; |
91 | 91 | } |
92 | 92 |
@@ -91,8 +91,9 @@ |
||
91 | 91 | // Remove options with empty values |
92 | 92 | $cleanedOptions = array(); |
93 | 93 | foreach ($options as $name=>$value) { |
94 | - if ($value!==null) |
|
95 | - $cleanedOptions[$name] = $value; |
|
94 | + if ($value!==null) { |
|
95 | + $cleanedOptions[$name] = $value; |
|
96 | + } |
|
96 | 97 | } |
97 | 98 | |
98 | 99 | return $cleanedOptions; |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | case 'status': $this->setStatus($value); break; |
86 | 86 | case 'description': $this->setDescription($value); break; |
87 | 87 | default: |
88 | - throw new Exception('Unknown option found in the Variation entity: ' . $name); |
|
88 | + throw new Exception('Unknown option found in the Variation entity: '.$name); |
|
89 | 89 | } |
90 | 90 | } |
91 | 91 | } |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | // Remove options with empty values |
114 | 114 | $cleanedOptions = array(); |
115 | 115 | foreach ($options as $name=>$value) { |
116 | - if ($value!==null) |
|
116 | + if ($value !== null) |
|
117 | 117 | $cleanedOptions[$name] = $value; |
118 | 118 | } |
119 | 119 |
@@ -91,8 +91,9 @@ |
||
91 | 91 | // Remove options with empty values |
92 | 92 | $cleanedOptions = array(); |
93 | 93 | foreach ($options as $name=>$value) { |
94 | - if ($value!==null) |
|
95 | - $cleanedOptions[$name] = $value; |
|
94 | + if ($value!==null) { |
|
95 | + $cleanedOptions[$name] = $value; |
|
96 | + } |
|
96 | 97 | } |
97 | 98 | |
98 | 99 | return $cleanedOptions; |
@@ -316,6 +316,9 @@ discard block |
||
316 | 316 | return $this->attributes; |
317 | 317 | } |
318 | 318 | |
319 | + /** |
|
320 | + * @param ChangeAttribute $attributes |
|
321 | + */ |
|
319 | 322 | public function setAttributes($attributes) |
320 | 323 | { |
321 | 324 | $this->attributes = $attributes; |
@@ -326,6 +329,9 @@ discard block |
||
326 | 329 | return $this->rearrange; |
327 | 330 | } |
328 | 331 | |
332 | + /** |
|
333 | + * @param string $rearrange |
|
334 | + */ |
|
329 | 335 | public function setRearrange($rearrange) |
330 | 336 | { |
331 | 337 | $this->rearrange = $rearrange; |
@@ -346,6 +352,9 @@ discard block |
||
346 | 352 | return $this->css; |
347 | 353 | } |
348 | 354 | |
355 | + /** |
|
356 | + * @param CssAttribute $css |
|
357 | + */ |
|
349 | 358 | public function setCss($css) |
350 | 359 | { |
351 | 360 | $this->css = $css; |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | case 'name': $this->setName($value); break; |
162 | 162 | case 'operator': $this->setOperator($value); break; |
163 | 163 | default: |
164 | - throw new Exception('Unknown option found in the Change entity: ' . $name); |
|
164 | + throw new Exception('Unknown option found in the Change entity: '.$name); |
|
165 | 165 | } |
166 | 166 | } |
167 | 167 | } |
@@ -183,10 +183,10 @@ discard block |
||
183 | 183 | 'value' => $this->getValue(), |
184 | 184 | 'id' => $this->getId(), |
185 | 185 | 'selector' => $this->getSelector(), |
186 | - 'attributes' => $this->getAttributes()?$this->getAttributes()->toArray():null, |
|
186 | + 'attributes' => $this->getAttributes() ? $this->getAttributes()->toArray() : null, |
|
187 | 187 | 'rearrange' => $this->getRearrange(), |
188 | 188 | 'config' => $this->getConfig(), |
189 | - 'css' => $this->getCss()?$this->getCss()->toArray():null, |
|
189 | + 'css' => $this->getCss() ? $this->getCss()->toArray() : null, |
|
190 | 190 | 'name' => $this->getName(), |
191 | 191 | 'operator' => $this->getOperator(), |
192 | 192 | ); |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | // Remove options with empty values |
195 | 195 | $cleanedOptions = array(); |
196 | 196 | foreach ($options as $name=>$value) { |
197 | - if ($value!==null) |
|
197 | + if ($value !== null) |
|
198 | 198 | $cleanedOptions[$name] = $value; |
199 | 199 | } |
200 | 200 |
@@ -91,8 +91,9 @@ |
||
91 | 91 | // Remove options with empty values |
92 | 92 | $cleanedOptions = array(); |
93 | 93 | foreach ($options as $name=>$value) { |
94 | - if ($value!==null) |
|
95 | - $cleanedOptions[$name] = $value; |
|
94 | + if ($value!==null) { |
|
95 | + $cleanedOptions[$name] = $value; |
|
96 | + } |
|
96 | 97 | } |
97 | 98 | |
98 | 99 | return $cleanedOptions; |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | case 'is_editable': $this->setIsEditable($value); break; |
133 | 133 | case 'config': $this->setConfig(new InPageEventConfig($value)); break; |
134 | 134 | default: |
135 | - throw new Exception('Unknown option found in the Event entity: ' . $name); |
|
135 | + throw new Exception('Unknown option found in the Event entity: '.$name); |
|
136 | 136 | } |
137 | 137 | } |
138 | 138 | } |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | 'category' => $this->getCategory(), |
149 | 149 | 'created' => $this->getCreated(), |
150 | 150 | 'description' => $this->getDescription(), |
151 | - 'event_filter' => $this->getEventFilter()?$this->getEventFilter()->toArray():null, |
|
151 | + 'event_filter' => $this->getEventFilter() ? $this->getEventFilter()->toArray() : null, |
|
152 | 152 | 'event_type' => $this->getEventType(), |
153 | 153 | 'key' => $this->getKey(), |
154 | 154 | 'name' => $this->getName(), |
@@ -157,13 +157,13 @@ discard block |
||
157 | 157 | 'id' => $this->getId(), |
158 | 158 | 'is_classic' => $this->getIsClassic(), |
159 | 159 | 'is_editable' => $this->getIsEditable(), |
160 | - 'config' => $this->getConfig()?$this->getConfig()->toArray():null, |
|
160 | + 'config' => $this->getConfig() ? $this->getConfig()->toArray() : null, |
|
161 | 161 | ); |
162 | 162 | |
163 | 163 | // Remove options with empty values |
164 | 164 | $cleanedOptions = array(); |
165 | 165 | foreach ($options as $name=>$value) { |
166 | - if ($value!==null) |
|
166 | + if ($value !== null) |
|
167 | 167 | $cleanedOptions[$name] = $value; |
168 | 168 | } |
169 | 169 |