@@ -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 ++; |
@@ -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; |
@@ -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; |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | case 'weight': $this->setWeight($value); break; |
| 79 | 79 | case 'status': $this->setStatus($value); break; |
| 80 | 80 | default: |
| 81 | - throw new Exception('Unknown option: ' . $name); |
|
| 81 | + throw new Exception('Unknown option: '.$name); |
|
| 82 | 82 | } |
| 83 | 83 | } |
| 84 | 84 | } |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | // Remove options with empty values |
| 106 | 106 | $cleanedOptions = array(); |
| 107 | 107 | foreach ($options as $name=>$value) { |
| 108 | - if ($value!==null) |
|
| 108 | + if ($value !== null) |
|
| 109 | 109 | $cleanedOptions[$name] = $value; |
| 110 | 110 | } |
| 111 | 111 | |
@@ -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 | |
@@ -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; |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | case 'last_modified': $this->setLastModified($value); break; |
| 94 | 94 | case 'is_classic': $this->getIsClassic($value); break; |
| 95 | 95 | default: |
| 96 | - throw new Exception('Unknown option: ' . $name); |
|
| 96 | + throw new Exception('Unknown option: '.$name); |
|
| 97 | 97 | } |
| 98 | 98 | } |
| 99 | 99 | } |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | // Remove options with empty values |
| 120 | 120 | $cleanedOptions = array(); |
| 121 | 121 | foreach ($options as $name=>$value) { |
| 122 | - if ($value!==null) |
|
| 122 | + if ($value !== null) |
|
| 123 | 123 | $cleanedOptions[$name] = $value; |
| 124 | 124 | } |
| 125 | 125 | |
@@ -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; |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | case 'socket_token': $this->setSocketToken($value); break; |
| 130 | 130 | case 'description': $this->setDescription($value); break; |
| 131 | 131 | default: |
| 132 | - throw new Exception('Unknown option found in the Project entity: ' . $name); |
|
| 132 | + throw new Exception('Unknown option found in the Project entity: '.$name); |
|
| 133 | 133 | } |
| 134 | 134 | } |
| 135 | 135 | } |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | 'platform' => $this->getPlatform(), |
| 148 | 148 | 'sdks' => $this->getSdks(), |
| 149 | 149 | 'status' => $this->getStatus(), |
| 150 | - 'web_snippet' => $this->getWebSnippet()?$this->getWebSnippet()->toArray():null, |
|
| 150 | + 'web_snippet' => $this->getWebSnippet() ? $this->getWebSnippet()->toArray() : null, |
|
| 151 | 151 | 'created' => $this->getCreated(), |
| 152 | 152 | 'id' => $this->getId(), |
| 153 | 153 | 'is_classic' => $this->getIsClassic(), |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | // Remove options with empty values |
| 160 | 160 | $cleanedOptions = array(); |
| 161 | 161 | foreach ($options as $name=>$value) { |
| 162 | - if ($value!==null) |
|
| 162 | + if ($value !== null) |
|
| 163 | 163 | $cleanedOptions[$name] = $value; |
| 164 | 164 | } |
| 165 | 165 | |