Completed
Push — master ( 091458...fe2892 )
by Oleg
03:56
created
examples/Utils.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -13,9 +13,9 @@  discard block
 block discarded – undo
13 13
 function load_credentials_from_file()
14 14
 {
15 15
     // Get OAuth 2.0 credentials from auth_credentials.json file.
16
-    $credentials = file_get_contents(dirname(__FILE__) . '/auth_credentials.json');
17
-    if ($credentials===false) {
18
-        throw new \Exception("Couldn't read OAuth credentials from auth_credentials.json. Make sure " .
16
+    $credentials = file_get_contents(dirname(__FILE__).'/auth_credentials.json');
17
+    if ($credentials === false) {
18
+        throw new \Exception("Couldn't read OAuth credentials from auth_credentials.json. Make sure ".
19 19
              "the file exists (if not, copy from auth_credentials.json.dist).");
20 20
     }
21 21
 
@@ -25,8 +25,8 @@  discard block
 block discarded – undo
25 25
     }
26 26
 
27 27
     // Try to read access_token.json and merge it with the rest of credentials.
28
-    if (is_readable(dirname(__FILE__) . '/access_token.json')) {
29
-        $accessToken = file_get_contents(dirname(__FILE__) . '/access_token.json');
28
+    if (is_readable(dirname(__FILE__).'/access_token.json')) {
29
+        $accessToken = file_get_contents(dirname(__FILE__).'/access_token.json');
30 30
 
31 31
         $accessToken = json_decode($accessToken, true);
32 32
         if (!is_array($accessToken)) {
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@
 block discarded – undo
16 16
     $credentials = file_get_contents(dirname(__FILE__) . '/auth_credentials.json');
17 17
     if ($credentials===false) {
18 18
         throw new \Exception("Couldn't read OAuth credentials from auth_credentials.json. Make sure " .
19
-             "the file exists (if not, copy from auth_credentials.json.dist).");
19
+                "the file exists (if not, copy from auth_credentials.json.dist).");
20 20
     }
21 21
 
22 22
     $credentials = json_decode($credentials, true);
Please login to merge, or discard this patch.
lib/WebMarketingROI/OptimizelyPHP/OptimizelyApiClient.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
      * @param array $queryParams The list of query parameters.
164 164
      * @param string $method HTTP method (GET or POST).
165 165
      * @param array $postData Data send in request body (only for POST method).
166
-     * @return array Optimizely response in form of array.
166
+     * @return Result Optimizely response in form of array.
167 167
      * @throws Exception
168 168
      */
169 169
     public function sendApiRequest($url, $queryParams = array(), $method='GET', 
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
      * @param array $queryParams The list of query parameters.
189 189
      * @param string $method HTTP method (GET or POST).
190 190
      * @param array $postData Data send in request body (only for POST method).
191
-     * @return array Optimizely response in form of array.
191
+     * @return Result Optimizely response in form of array.
192 192
      * @throws Exception
193 193
      */
194 194
     private function sendHttpRequest($url, $queryParams = array(), $method='GET', 
Please login to merge, or discard this patch.
Braces   +13 added lines, -8 removed lines patch added patch discarded remove patch
@@ -265,8 +265,10 @@  discard block
 block discarded – undo
265 265
         $headers = explode("\n", $headers);
266 266
         $parsedHeaders = array();
267 267
         foreach ($headers as $i=>$header) {
268
-            if ($i==0)
269
-                continue; // Skip first line (http code).
268
+            if ($i==0) {
269
+                            continue;
270
+            }
271
+            // Skip first line (http code).
270 272
             $pos = strpos($header, ':');
271 273
             if ($pos!=false) {
272 274
                 $headerName = trim(strtolower(substr($header, 0, $pos)));
@@ -419,14 +421,17 @@  discard block
 block discarded – undo
419 421
      */
420 422
     private function getAccessTokenByRefreshToken()
421 423
     {
422
-        if (!isset($this->authCredentials['client_id']))
423
-            throw new Exception('OAuth 2.0 client ID is not set');
424
+        if (!isset($this->authCredentials['client_id'])) {
425
+                    throw new Exception('OAuth 2.0 client ID is not set');
426
+        }
424 427
         
425
-        if (!isset($this->authCredentials['client_secret']))
426
-            throw new Exception('OAuth 2.0 client secret is not set');
428
+        if (!isset($this->authCredentials['client_secret'])) {
429
+                    throw new Exception('OAuth 2.0 client secret is not set');
430
+        }
427 431
         
428
-        if (!isset($this->authCredentials['refresh_token']))
429
-            throw new Exception('Refresh token is not set');
432
+        if (!isset($this->authCredentials['refresh_token'])) {
433
+                    throw new Exception('Refresh token is not set');
434
+        }
430 435
         
431 436
         $clientId = $this->authCredentials['client_id'];
432 437
         $clientSecret = $this->authCredentials['client_secret'];
Please login to merge, or discard this patch.
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -50,13 +50,13 @@  discard block
 block discarded – undo
50 50
      * @param array $authCredentials Auth credentials.
51 51
      * @param string $apiVersion Optional. Currently supported 'v2' only.     
52 52
      */
53
-    public function __construct($authCredentials, $apiVersion='v2')
53
+    public function __construct($authCredentials, $apiVersion = 'v2')
54 54
     {
55 55
         if (!is_array($authCredentials)) {
56 56
             throw new Exception('Auth credentials must be an array');            
57 57
         }
58 58
         
59
-        if ($apiVersion!='v2') {
59
+        if ($apiVersion != 'v2') {
60 60
             throw new Exception('Invalid API version passed');
61 61
         }
62 62
         
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
      */
86 86
     public function setApiVersion($apiVersion)
87 87
     {
88
-        if ($apiVersion!='v2') {
88
+        if ($apiVersion != 'v2') {
89 89
             throw new Exception('Invalid API version passed');
90 90
         }
91 91
         
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
      */
108 108
     public function setAuthCredentials($authCredentials)
109 109
     {
110
-        if (!is_array($authCredentials) || count($authCredentials)==0) {
110
+        if (!is_array($authCredentials) || count($authCredentials) == 0) {
111 111
             throw new Exception('Auth credentials must be an non-empty array');            
112 112
         }
113 113
         
@@ -166,16 +166,16 @@  discard block
 block discarded – undo
166 166
      * @return array Optimizely response in form of array.
167 167
      * @throws Exception
168 168
      */
169
-    public function sendApiRequest($url, $queryParams = array(), $method='GET', 
169
+    public function sendApiRequest($url, $queryParams = array(), $method = 'GET', 
170 170
             $postData = array())
171 171
     {
172 172
         // If access token has expired, try to get another one with refresh token.
173
-        if ($this->isAccessTokenExpired() && $this->getRefreshToken()!=null) {
173
+        if ($this->isAccessTokenExpired() && $this->getRefreshToken() != null) {
174 174
             $this->getAccessTokenByRefreshToken();
175 175
         }
176 176
         
177 177
         // Produce absolute URL
178
-        $url = 'https://api.optimizely.com/' . $this->apiVersion . $url;
178
+        $url = 'https://api.optimizely.com/'.$this->apiVersion.$url;
179 179
         
180 180
         $result = $this->sendHttpRequest($url, $queryParams, $method, $postData);
181 181
         
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
      * @return array Optimizely response in form of array.
192 192
      * @throws Exception
193 193
      */
194
-    private function sendHttpRequest($url, $queryParams = array(), $method='GET', 
194
+    private function sendHttpRequest($url, $queryParams = array(), $method = 'GET', 
195 195
             $postData = array())
196 196
     {
197 197
         // Reset diagnostics info.
@@ -199,36 +199,36 @@  discard block
 block discarded – undo
199 199
         
200 200
         // Check if CURL is initialized (it should have been initialized in 
201 201
         // constructor).
202
-        if ($this->curlHandle==false) {
202
+        if ($this->curlHandle == false) {
203 203
             throw new Exception('CURL is not initialized', 
204 204
                     Exception::CODE_CURL_ERROR);
205 205
         }
206 206
         
207
-        if ($method!='GET' && $method!='POST' && $method!='PUT' && 
208
-            $method!='PATCH' && $method!='DELETE') {
209
-            throw new Exception('Invalid HTTP method passed: ' . $method);
207
+        if ($method != 'GET' && $method != 'POST' && $method != 'PUT' && 
208
+            $method != 'PATCH' && $method != 'DELETE') {
209
+            throw new Exception('Invalid HTTP method passed: '.$method);
210 210
         }
211 211
         
212 212
         if (!isset($this->authCredentials['access_token'])) {
213
-            throw new Exception('OAuth access token is not set. You should pass ' . 
213
+            throw new Exception('OAuth access token is not set. You should pass '. 
214 214
                     'it to the class constructor when initializing the Optimizely client.');
215 215
         }
216 216
                 
217 217
         // Append query parameters to URL.
218
-        if (count($queryParams)!=0) {            
218
+        if (count($queryParams) != 0) {            
219 219
             $query = http_build_query($queryParams);
220
-            $url .= '?' . $query;
220
+            $url .= '?'.$query;
221 221
         }
222 222
         
223 223
         $headers = array(
224
-            "Authorization: Bearer " . $this->authCredentials['access_token'],
224
+            "Authorization: Bearer ".$this->authCredentials['access_token'],
225 225
             "Content-Type: application/json"
226 226
             );
227 227
         $content = '';
228
-        if (count($postData)!=0) {
228
+        if (count($postData) != 0) {
229 229
             $content = json_encode($postData);            
230 230
         }
231
-        $headers[] = "Content-length:" . strlen($content);            
231
+        $headers[] = "Content-length:".strlen($content);            
232 232
         
233 233
         // Reset CURL state.
234 234
         if (!function_exists('curl_reset')) {
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
         // Set HTTP options.
242 242
         curl_setopt($this->curlHandle, CURLOPT_URL, $url);
243 243
         curl_setopt($this->curlHandle, CURLOPT_CUSTOMREQUEST, $method);        
244
-        if (count($postData)!=0) {
244
+        if (count($postData) != 0) {
245 245
             curl_setopt($this->curlHandle, CURLOPT_POSTFIELDS, $content);            
246 246
         }
247 247
         curl_setopt($this->curlHandle, CURLOPT_RETURNTRANSFER, true);
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
         if ($result === false) {
261 261
             $code = curl_errno($this->curlHandle);
262 262
             $error = curl_error($this->curlHandle);
263
-            throw new Exception("Failed to send HTTP request $method '$url', " . 
263
+            throw new Exception("Failed to send HTTP request $method '$url', ". 
264 264
                     "the error code was $code, error message was: '$error'", 
265 265
                     Exception::CODE_CURL_ERROR, $code, $error);
266 266
         }        
@@ -274,12 +274,12 @@  discard block
 block discarded – undo
274 274
         $headers = explode("\n", $headers);
275 275
         $parsedHeaders = array();
276 276
         foreach ($headers as $i=>$header) {
277
-            if ($i==0)
277
+            if ($i == 0)
278 278
                 continue; // Skip first line (http code).
279 279
             $pos = strpos($header, ':');
280
-            if ($pos!=false) {
280
+            if ($pos != false) {
281 281
                 $headerName = trim(strtolower(substr($header, 0, $pos)));
282
-                $headerValue = trim(substr($header, $pos+1));
282
+                $headerValue = trim(substr($header, $pos + 1));
283 283
                 $parsedHeaders[$headerName] = $headerValue;
284 284
             }
285 285
         }
@@ -311,20 +311,20 @@  discard block
 block discarded – undo
311 311
         
312 312
         // JSON-decode payload.
313 313
         $decodedPayload = json_decode($body, true);
314
-        if ($decodedPayload===false) {
315
-            throw new Exception('Could not JSON-decode the Optimizely API response. Request was ' . 
316
-                    $method . ' "' . $url . '". The response was: "' . $body . '"',
314
+        if ($decodedPayload === false) {
315
+            throw new Exception('Could not JSON-decode the Optimizely API response. Request was '. 
316
+                    $method.' "'.$url.'". The response was: "'.$body.'"',
317 317
                     Exception::CODE_API_ERROR, array('http_code'=>$httpCode));
318 318
         }
319 319
         
320 320
         // Check HTTP response code.
321
-        if ($httpCode<200 || $httpCode>299) {
321
+        if ($httpCode < 200 || $httpCode > 299) {
322 322
             
323 323
             if (!isset($decodedPayload['message']) || 
324 324
                 !isset($decodedPayload['code']) ||
325 325
                 !isset($decodedPayload['uuid'])) {
326
-                throw new Exception('Optimizely API responded with error code ' . $httpCode . 
327
-                    '. Request was ' . $method . ' "' . $url . '". Response was "' . $body . '"',
326
+                throw new Exception('Optimizely API responded with error code '.$httpCode. 
327
+                    '. Request was '.$method.' "'.$url.'". Response was "'.$body.'"',
328 328
                     Exception::CODE_API_ERROR, array(
329 329
                         'http_code' => $httpCode,
330 330
                         'rate_limit' => $rateLimit,
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
             $matched = preg_match_all('/<(.+)>;\s+rel=(\w+)(,|\z)/U', 
357 357
                     $parsedHeaders['link'], $matches, PREG_SET_ORDER);
358 358
             if (!$matched) {
359
-                throw new Exception('Error parsing LINK header: ' . 
359
+                throw new Exception('Error parsing LINK header: '. 
360 360
                         $parsedHeaders['link'], Exception::CODE_API_ERROR, $httpCode);
361 361
             }
362 362
             
@@ -366,22 +366,22 @@  discard block
 block discarded – undo
366 366
                 $rel = $match[2];
367 367
                 
368 368
                 $matched = preg_match('/page=(\d+)/U', $url, $pageMatches);
369
-                if (!$matched || count($pageMatches)!=2) {
370
-                    throw new Exception('Error extracting page argument while parsing LINK header: ' . 
369
+                if (!$matched || count($pageMatches) != 2) {
370
+                    throw new Exception('Error extracting page argument while parsing LINK header: '. 
371 371
                             $parsedHeaders['link'], Exception::CODE_API_ERROR, 
372 372
                             array('http_code'=>$httpCode));
373 373
                 }
374 374
                 
375 375
                 $pageNumber = $pageMatches[1];
376 376
                 
377
-                if ($rel=='prev') {
377
+                if ($rel == 'prev') {
378 378
                     $result->setPrevPage($pageNumber);
379
-                } else if ($rel=='next') {
379
+                } else if ($rel == 'next') {
380 380
                     $result->setNextPage($pageNumber);
381
-                } else if ($rel=='last') {
381
+                } else if ($rel == 'last') {
382 382
                     $result->setLastPage($pageNumber);
383 383
                 } else {
384
-                    throw new Exception('Unexpected rel argument while parsing LINK header: ' . 
384
+                    throw new Exception('Unexpected rel argument while parsing LINK header: '. 
385 385
                             $parsedHeaders['link'], Exception::CODE_API_ERROR, 
386 386
                             array('http_code'=>$httpCode));
387 387
                 }
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
      */
400 400
     private function isAccessTokenExpired() 
401 401
     {
402
-        if(!isset($this->authCredentials['access_token'])) {
402
+        if (!isset($this->authCredentials['access_token'])) {
403 403
             return true; // We do not have access token.
404 404
         }
405 405
         
@@ -440,15 +440,15 @@  discard block
 block discarded – undo
440 440
         $clientSecret = $this->authCredentials['client_secret'];
441 441
         $refreshToken = $this->authCredentials['refresh_token'];
442 442
         
443
-        $url = "https://app.optimizely.com/oauth2/token?refresh_token=$refreshToken" . 
443
+        $url = "https://app.optimizely.com/oauth2/token?refresh_token=$refreshToken". 
444 444
                 "&client_id=$clientId&client_secret=$clientSecret&grant_type=refresh_token";
445 445
         
446 446
         $response = $this->sendHttpRequest($url, array(), 'POST');
447 447
         $decodedJsonData = $response->getDecodedJsonData();
448 448
         
449 449
         if (!isset($decodedJsonData['access_token'])) {
450
-            throw new Exception('Not found access token in response. Request URL was "' . 
451
-                    $url. '". Response was "' . print_r(json_encode($decodedJsonData), true). '"',
450
+            throw new Exception('Not found access token in response. Request URL was "'. 
451
+                    $url.'". Response was "'.print_r(json_encode($decodedJsonData), true).'"',
452 452
                     Exception::CODE_API_ERROR, $response->getHttpCode());
453 453
         }
454 454
         
Please login to merge, or discard this patch.
tests/OptimizelyPHPTest/Service/v2/ExperimentsTest.php 2 patches
Indentation   +179 added lines, -179 removed lines patch added patch discarded remove patch
@@ -23,20 +23,20 @@  discard block
 block discarded – undo
23 23
                         array(
24 24
                             "project_id" => 1000,
25 25
                             "audience_ids" => array(
26
-                              1234,
27
-                              1212,
28
-                              1432
26
+                                1234,
27
+                                1212,
28
+                                1432
29 29
                             ),
30 30
                             "campaign_id" => 2000,
31 31
                             "changes" => array(
32
-                              array(
32
+                                array(
33 33
                                 "type" => "custom_code",
34 34
                                 "allow_additional_redirect" => true,
35 35
                                 "async" => true,
36 36
                                 "css_selector" => "a[href*=\"optimizely\"]",
37 37
                                 "dependencies" => array(
38
-                                  24,
39
-                                  26
38
+                                    24,
39
+                                    26
40 40
                                 ),
41 41
                                 "destination" => "https://app.optimizely.com/",
42 42
                                 "extension_id" => 1234,
@@ -44,37 +44,37 @@  discard block
 block discarded – undo
44 44
                                 "src" => 524,
45 45
                                 "value" => "window.someGlobalFunction();",
46 46
                                 "id" => "string"
47
-                              )
47
+                                )
48 48
                             ),
49 49
                             "description" => "string",
50 50
                             "holdback" => 5000,
51 51
                             "key" => "home_page_experiment",
52 52
                             "metrics" => array(
53
-                              array(
53
+                                array(
54 54
                                 "kind" => "string",
55 55
                                 "id" => 0
56
-                              )
56
+                                )
57 57
                             ),
58 58
                             "name" => "Blue Button Experiment",
59 59
                             "schedule" => array(
60
-                              "start_time" => "2016-10-17T07:05:00.070Z",
61
-                              "stop_time" => "2016-10-17T07:05:00.070Z",
62
-                              "time_zone" => "UTC"
60
+                                "start_time" => "2016-10-17T07:05:00.070Z",
61
+                                "stop_time" => "2016-10-17T07:05:00.070Z",
62
+                                "time_zone" => "UTC"
63 63
                             ),
64 64
                             "status" => "active",
65 65
                             "variations" => array(
66
-                              array(
66
+                                array(
67 67
                                 "actions" => array(
68
-                                  array(
68
+                                    array(
69 69
                                     "changes" => array(
70
-                                      array(
70
+                                        array(
71 71
                                         "type" => "custom_code",
72 72
                                         "allow_additional_redirect" => true, 
73 73
                                         "async" => true,
74 74
                                         "css_selector" => "a[href*=\"optimizely\"]",
75 75
                                         "dependencies" => array(
76
-                                          24,
77
-                                          26
76
+                                            24,
77
+                                            26
78 78
                                         ),
79 79
                                         "destination" => "https://app.optimizely.com/",
80 80
                                         "extension_id" => 1234,
@@ -82,23 +82,23 @@  discard block
 block discarded – undo
82 82
                                         "src" => 524,
83 83
                                         "value" => "window.someGlobalFunction();",
84 84
                                         "id" => "string"
85
-                                      )
85
+                                        )
86 86
                                     ),
87 87
                                     "page_id" => 0
88
-                                  )
88
+                                    )
89 89
                                 ),
90 90
                                 "archived"=> true,
91 91
                                 "key" => "blue_button_variation",
92 92
                                 "name" => "Blue Button",
93 93
                                 "variation_id" => 0,
94 94
                                 "weight" => 0
95
-                              )
95
+                                )
96 96
                             ),
97 97
                             "created" => "2016-10-17T07:05:00.070Z",
98 98
                             "id" => 3000,
99 99
                             "is_classic" => false,
100 100
                             "last_modified" => "2016-10-17T07:05:00.070Z"
101
-                          )
101
+                            )
102 102
                         ), 200);
103 103
         
104 104
         $optimizelyApiClientMock->method('sendApiRequest')
@@ -124,20 +124,20 @@  discard block
 block discarded – undo
124 124
         $result = new Result(array(
125 125
                             "project_id" => 1000,
126 126
                             "audience_ids" => array(
127
-                              1234,
128
-                              1212,
129
-                              1432
127
+                                1234,
128
+                                1212,
129
+                                1432
130 130
                             ),
131 131
                             "campaign_id" => 2000,
132 132
                             "changes" => array(
133
-                              array(
133
+                                array(
134 134
                                 "type" => "custom_code",
135 135
                                 "allow_additional_redirect" => true,
136 136
                                 "async" => true,
137 137
                                 "css_selector" => "a[href*=\"optimizely\"]",
138 138
                                 "dependencies" => array(
139
-                                  24,
140
-                                  26
139
+                                    24,
140
+                                    26
141 141
                                 ),
142 142
                                 "destination" => "https://app.optimizely.com/",
143 143
                                 "extension_id" => 1234,
@@ -145,37 +145,37 @@  discard block
 block discarded – undo
145 145
                                 "src" => 524,
146 146
                                 "value" => "window.someGlobalFunction();",
147 147
                                 "id" => "string"
148
-                              )
148
+                                )
149 149
                             ),
150 150
                             "description" => "string",
151 151
                             "holdback" => 5000,
152 152
                             "key" => "home_page_experiment",
153 153
                             "metrics" => array(
154
-                              array(
154
+                                array(
155 155
                                 "kind" => "string",
156 156
                                 "id" => 0
157
-                              )
157
+                                )
158 158
                             ),
159 159
                             "name" => "Blue Button Experiment",
160 160
                             "schedule" => array(
161
-                              "start_time" => "2016-10-17T07:05:00.070Z",
162
-                              "stop_time" => "2016-10-17T07:05:00.070Z",
163
-                              "time_zone" => "UTC"
161
+                                "start_time" => "2016-10-17T07:05:00.070Z",
162
+                                "stop_time" => "2016-10-17T07:05:00.070Z",
163
+                                "time_zone" => "UTC"
164 164
                             ),
165 165
                             "status" => "active",
166 166
                             "variations" => array(
167
-                              array(
167
+                                array(
168 168
                                 "actions" => array(
169
-                                  array(
169
+                                    array(
170 170
                                     "changes" => array(
171
-                                      array(
171
+                                        array(
172 172
                                         "type" => "custom_code",
173 173
                                         "allow_additional_redirect" => true, 
174 174
                                         "async" => true,
175 175
                                         "css_selector" => "a[href*=\"optimizely\"]",
176 176
                                         "dependencies" => array(
177
-                                          24,
178
-                                          26
177
+                                            24,
178
+                                            26
179 179
                                         ),
180 180
                                         "destination" => "https://app.optimizely.com/",
181 181
                                         "extension_id" => 1234,
@@ -183,23 +183,23 @@  discard block
 block discarded – undo
183 183
                                         "src" => 524,
184 184
                                         "value" => "window.someGlobalFunction();",
185 185
                                         "id" => "string"
186
-                                      )
186
+                                        )
187 187
                                     ),
188 188
                                     "page_id" => 0
189
-                                  )
189
+                                    )
190 190
                                 ),
191 191
                                 "archived"=> true,
192 192
                                 "key" => "blue_button_variation",
193 193
                                 "name" => "Blue Button",
194 194
                                 "variation_id" => 0,
195 195
                                 "weight" => 0
196
-                              )
196
+                                )
197 197
                             ),
198 198
                             "created" => "2016-10-17T07:05:00.070Z",
199 199
                             "id" => 3000,
200 200
                             "is_classic" => false,
201 201
                             "last_modified" => "2016-10-17T07:05:00.070Z"
202
-                          ), 200);
202
+                            ), 200);
203 203
         
204 204
         $optimizelyApiClientMock->method('sendApiRequest')
205 205
                     ->willReturn($result);
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
                             "end_time" => "2016-10-17T07:05:00.089Z",
226 226
                             "experiment_id" => 3000,
227 227
                             "metrics" => array(
228
-                              array(
228
+                                array(
229 229
                                 "event" => "string",
230 230
                                 "event_name" => "string",
231 231
                                 "measure" => "conversions",
@@ -233,54 +233,54 @@  discard block
 block discarded – undo
233 233
                                 "priority" => 1,
234 234
                                 "unit" => "session",
235 235
                                 "variation_results" => array(
236
-                                  "9000" => array(
236
+                                    "9000" => array(
237 237
                                     "experiment_id" => 0,
238 238
                                     "is_baseline" => true,
239 239
                                     "lift" => array(
240
-                                      "confidence_interval" => array(
240
+                                        "confidence_interval" => array(
241 241
                                         0.010399560300730457,
242 242
                                         0.0850821459929161
243
-                                      ),
244
-                                      "is_most_conclusive" => true,
245
-                                      "is_significant" => true,
246
-                                      "significance" => 0,
247
-                                      "value" => 0,
248
-                                      "visitors_remaining" => 0
243
+                                        ),
244
+                                        "is_most_conclusive" => true,
245
+                                        "is_significant" => true,
246
+                                        "significance" => 0,
247
+                                        "value" => 0,
248
+                                        "visitors_remaining" => 0
249 249
                                     ),
250 250
                                     "name" => "Blue Button",
251 251
                                     "rate" => 0,
252 252
                                     "scope" => "variation",
253 253
                                     "total_increase" => array(
254
-                                      "confidence_interval" => array(
254
+                                        "confidence_interval" => array(
255 255
                                         0.010399560300730457,
256 256
                                         0.0850821459929161
257
-                                      ),
258
-                                      "is_most_conclusive" => true,
259
-                                      "is_significant" => true,
260
-                                      "significance" => 0,
261
-                                      "value" => 0,
262
-                                      "visitors_remaining" => 0
257
+                                        ),
258
+                                        "is_most_conclusive" => true,
259
+                                        "is_significant" => true,
260
+                                        "significance" => 0,
261
+                                        "value" => 0,
262
+                                        "visitors_remaining" => 0
263 263
                                     ),
264 264
                                     "value" => 0,
265 265
                                     "variation_id" => "string"
266
-                                  )
266
+                                    )
267
+                                )
267 268
                                 )
268
-                              )
269 269
                             ),
270 270
                             "reach" => array(
271
-                              "baseline_count" => 0,
272
-                              "baseline_reach" => 0,
273
-                              "total_count" => 0,
274
-                              "treatment_count" => 0,
275
-                              "treatment_reach" => 0,
276
-                              "variations" => array(
271
+                                "baseline_count" => 0,
272
+                                "baseline_reach" => 0,
273
+                                "total_count" => 0,
274
+                                "treatment_count" => 0,
275
+                                "treatment_reach" => 0,
276
+                                "variations" => array(
277 277
                                 "9000" => array(
278
-                                  "count" => 0,
279
-                                  "name" => "Blue Button",
280
-                                  "variation_id" => "string",
281
-                                  "variation_reach" => 0
278
+                                    "count" => 0,
279
+                                    "name" => "Blue Button",
280
+                                    "variation_id" => "string",
281
+                                    "variation_reach" => 0
282
+                                )
282 283
                                 )
283
-                              )
284 284
                             ),
285 285
                             "start_time" => "2016-10-17T07:05:00.090Z"
286 286
                         ), 200);
@@ -307,20 +307,20 @@  discard block
 block discarded – undo
307 307
         $result = new Result(array(
308 308
                             "project_id" => 1000,
309 309
                             "audience_ids" => array(
310
-                              1234,
311
-                              1212,
312
-                              1432
310
+                                1234,
311
+                                1212,
312
+                                1432
313 313
                             ),
314 314
                             "campaign_id" => 2000,
315 315
                             "changes" => array(
316
-                              array(
316
+                                array(
317 317
                                 "type" => "custom_code",
318 318
                                 "allow_additional_redirect" => true,
319 319
                                 "async" => true,
320 320
                                 "css_selector" => "a[href*=\"optimizely\"]",
321 321
                                 "dependencies" => array(
322
-                                  24,
323
-                                  26
322
+                                    24,
323
+                                    26
324 324
                                 ),
325 325
                                 "destination" => "https://app.optimizely.com/",
326 326
                                 "extension_id" => 1234,
@@ -328,37 +328,37 @@  discard block
 block discarded – undo
328 328
                                 "src" => 524,
329 329
                                 "value" => "window.someGlobalFunction();",
330 330
                                 "id" => "string"
331
-                              )
331
+                                )
332 332
                             ),
333 333
                             "description" => "string",
334 334
                             "holdback" => 5000,
335 335
                             "key" => "home_page_experiment",
336 336
                             "metrics" => array(
337
-                              array(
337
+                                array(
338 338
                                 "kind" => "string",
339 339
                                 "id" => 0
340
-                              )
340
+                                )
341 341
                             ),
342 342
                             "name" => "Blue Button Experiment",
343 343
                             "schedule" => array(
344
-                              "start_time" => "2016-10-17T07:05:00.099Z",
345
-                              "stop_time" => "2016-10-17T07:05:00.099Z",
346
-                              "time_zone" => "UTC"
344
+                                "start_time" => "2016-10-17T07:05:00.099Z",
345
+                                "stop_time" => "2016-10-17T07:05:00.099Z",
346
+                                "time_zone" => "UTC"
347 347
                             ),
348 348
                             "status" => "active",
349 349
                             "variations" => array(
350
-                              array(
350
+                                array(
351 351
                                 "actions" => array(
352
-                                  array(
352
+                                    array(
353 353
                                     "changes" => array(
354
-                                      array(
354
+                                        array(
355 355
                                         "type" => "custom_code",
356 356
                                         "allow_additional_redirect" => true,
357 357
                                         "async" => true,
358 358
                                         "css_selector" => "a[href*=\"optimizely\"]",
359 359
                                         "dependencies" => array(
360
-                                          24,
361
-                                          26
360
+                                            24,
361
+                                            26
362 362
                                         ),
363 363
                                         "destination" => "https://app.optimizely.com/",
364 364
                                         "extension_id" => 1234,
@@ -366,17 +366,17 @@  discard block
 block discarded – undo
366 366
                                         "src" => 524,
367 367
                                         "value" => "window.someGlobalFunction();",
368 368
                                         "id" => "string"
369
-                                      )
369
+                                        )
370 370
                                     ),
371 371
                                     "page_id" => 0
372
-                                  )
372
+                                    )
373 373
                                 ),
374 374
                                 "archived" => true,
375 375
                                 "key" => "blue_button_variation",
376 376
                                 "name" => "Blue Button",
377 377
                                 "variation_id" => 0,
378 378
                                 "weight" => 0
379
-                              )
379
+                                )
380 380
                             ),
381 381
                             "created" => "2016-10-17T07:05:00.099Z",
382 382
                             "id" => 3000,
@@ -392,73 +392,73 @@  discard block
 block discarded – undo
392 392
         $experiment = new Experiment(array(
393 393
             "project_id" => 1000,
394 394
             "audience_ids" => array(
395
-              1234,
396
-              1212,
397
-              1432
395
+                1234,
396
+                1212,
397
+                1432
398 398
             ),
399 399
             "campaign_id" => 2000,
400 400
             "changes" => array(
401
-              array(
401
+                array(
402 402
                 "type" => "custom_code",
403 403
                 "allow_additional_redirect" => true,
404 404
                 "async" => true,
405 405
                 "css_selector" => "a[href*=\"optimizely\"]",
406 406
                 "dependencies" => array(
407
-                  24,
408
-                  26
407
+                    24,
408
+                    26
409 409
                 ),
410 410
                 "destination" => "https://app.optimizely.com/",
411 411
                 "extension_id" => 1234,
412 412
                 "preserve_parameters" => true,
413 413
                 "src" => 524,
414 414
                 "value" => "window.someGlobalFunction();"
415
-              )
415
+                )
416 416
             ),
417 417
             "description" => "string",
418 418
             "holdback" => 5000,
419 419
             "key" => "home_page_experiment",
420 420
             "metrics" => array(
421
-              array(
421
+                array(
422 422
                 "kind" => "string"
423
-              )
423
+                )
424 424
             ),
425 425
             "name" => "Blue Button Experiment",
426 426
             "schedule" => array(
427
-              "start_time" => "2016-10-17T07:04:59.724Z",
428
-              "stop_time" => "2016-10-17T07:04:59.724Z",
429
-              "time_zone" => "UTC"
427
+                "start_time" => "2016-10-17T07:04:59.724Z",
428
+                "stop_time" => "2016-10-17T07:04:59.724Z",
429
+                "time_zone" => "UTC"
430 430
             ),
431 431
             "status" => "active",
432 432
             "variations" => array(
433
-              array(
433
+                array(
434 434
                 "actions" => array(
435
-                  array(
435
+                    array(
436 436
                     "changes" => array(
437
-                      array(
437
+                        array(
438 438
                         "type" => "custom_code",
439 439
                         "allow_additional_redirect" => true,
440 440
                         "async" => true,
441 441
                         "css_selector" => "a[href*=\"optimizely\"]",
442 442
                         "dependencies" => array(
443
-                          24,
444
-                          26
443
+                            24,
444
+                            26
445 445
                         ),
446 446
                         "destination" => "https://app.optimizely.com/",
447 447
                         "extension_id" => 1234,
448 448
                         "preserve_parameters" => true,
449 449
                         "src" => 524,
450 450
                         "value" => "window.someGlobalFunction();"
451
-                      )
451
+                        )
452 452
                     ),
453 453
                     "page_id" => 0
454
-                  )
454
+                    )
455 455
                 ),
456 456
                 "archived" => true,
457 457
                 "key" => "blue_button_variation",
458 458
                 "name" => "Blue Button",
459 459
                 "variation_id" => 0,
460 460
                 "weight" => 0
461
-              )
461
+                )
462 462
             )
463 463
         ));
464 464
         
@@ -479,20 +479,20 @@  discard block
 block discarded – undo
479 479
         $result = new Result(array(
480 480
                         "project_id" => 1000,
481 481
                         "audience_ids" => array(
482
-                          1234,
483
-                          1212,
484
-                          1432
482
+                            1234,
483
+                            1212,
484
+                            1432
485 485
                         ),
486 486
                         "campaign_id" => 2000,
487 487
                         "changes" => array(
488
-                          array(
488
+                            array(
489 489
                             "type" => "custom_code",
490 490
                             "allow_additional_redirect" => true,
491 491
                             "async" => true,
492 492
                             "css_selector" => "a[href*=\"optimizely\"]",
493 493
                             "dependencies" => array(
494
-                              24,
495
-                              26
494
+                                24,
495
+                                26
496 496
                             ),
497 497
                             "destination" => "https://app.optimizely.com/",
498 498
                             "extension_id" => 1234,
@@ -500,37 +500,37 @@  discard block
 block discarded – undo
500 500
                             "src" => 524,
501 501
                             "value" => "window.someGlobalFunction();",
502 502
                             "id" => "string"
503
-                          )
503
+                            )
504 504
                         ),
505 505
                         "description" => "string",
506 506
                         "holdback" => 5000,
507 507
                         "key" => "home_page_experiment",
508 508
                         "metrics" => array(
509
-                          array(
509
+                            array(
510 510
                             "kind" => "string",
511 511
                             "id" => 0
512
-                          )
512
+                            )
513 513
                         ),
514 514
                         "name" => "Blue Button Experiment",
515 515
                         "schedule" => array(
516
-                          "start_time" => "2016-10-17T07:05:00.109Z",
517
-                          "stop_time" => "2016-10-17T07:05:00.109Z",
518
-                          "time_zone" => "UTC"
516
+                            "start_time" => "2016-10-17T07:05:00.109Z",
517
+                            "stop_time" => "2016-10-17T07:05:00.109Z",
518
+                            "time_zone" => "UTC"
519 519
                         ),
520 520
                         "status" => "active",
521 521
                         "variations" => array(
522
-                          array(
522
+                            array(
523 523
                             "actions" => array(
524
-                              array(
524
+                                array(
525 525
                                 "changes" => array(
526
-                                  array(
526
+                                    array(
527 527
                                     "type" => "custom_code",
528 528
                                     "allow_additional_redirect" => true,
529 529
                                     "async" => true,
530 530
                                     "css_selector" => "a[href*=\"optimizely\"]",
531 531
                                     "dependencies" => array(
532
-                                      24,
533
-                                      26
532
+                                        24,
533
+                                        26
534 534
                                     ),
535 535
                                     "destination" => "https://app.optimizely.com/",
536 536
                                     "extension_id" => 1234,
@@ -538,17 +538,17 @@  discard block
 block discarded – undo
538 538
                                     "src" => 524,
539 539
                                     "value" => "window.someGlobalFunction();",
540 540
                                     "id" => "string"
541
-                                  )
541
+                                    )
542 542
                                 ),
543 543
                                 "page_id" => 0
544
-                              )
544
+                                )
545 545
                             ),
546 546
                             "archived" => true,
547 547
                             "key" => "blue_button_variation",
548 548
                             "name" => "Blue Button",
549 549
                             "variation_id" => 0,
550 550
                             "weight" => 0
551
-                          )
551
+                            )
552 552
                         ),
553 553
                         "created" => "2016-10-17T07:05:00.109Z",
554 554
                         "id" => 3000,
@@ -562,72 +562,72 @@  discard block
 block discarded – undo
562 562
         $experimentsService = new Experiments($optimizelyApiClientMock);
563 563
         
564 564
         $experiment = new Experiment(array(
565
-              "audience_ids" => array(
565
+                "audience_ids" => array(
566 566
                 0
567
-              ),
568
-              "changes" => array(
567
+                ),
568
+                "changes" => array(
569 569
                 array(
570
-                  "type" => "custom_code",
571
-                  "allow_additional_redirect" => true,
572
-                  "async" => true,
573
-                  "css_selector" => "a[href*=\"optimizely\"]",
574
-                  "dependencies" => array(
570
+                    "type" => "custom_code",
571
+                    "allow_additional_redirect" => true,
572
+                    "async" => true,
573
+                    "css_selector" => "a[href*=\"optimizely\"]",
574
+                    "dependencies" => array(
575 575
                     24,
576 576
                     26
577
-                  ),
578
-                  "destination" => "https://app.optimizely.com/",
579
-                  "extension_id" => 1234,
580
-                  "preserve_parameters" => true,
581
-                  "src" => 524,
582
-                  "value" => "window.someGlobalFunction();"
577
+                    ),
578
+                    "destination" => "https://app.optimizely.com/",
579
+                    "extension_id" => 1234,
580
+                    "preserve_parameters" => true,
581
+                    "src" => 524,
582
+                    "value" => "window.someGlobalFunction();"
583 583
                 )
584
-              ),
585
-              "description" => "AB Test to see if the Blue Button converts more visitors",
586
-              "holdback" => 0,
587
-              "key" => "home_page_experiment",
588
-              "metrics" => array(
584
+                ),
585
+                "description" => "AB Test to see if the Blue Button converts more visitors",
586
+                "holdback" => 0,
587
+                "key" => "home_page_experiment",
588
+                "metrics" => array(
589 589
                 array(
590
-                  "kind" => "string"
590
+                    "kind" => "string"
591 591
                 )
592
-              ),
593
-              "name" => "Blue Button Experiment",
594
-              "schedule" => array(
592
+                ),
593
+                "name" => "Blue Button Experiment",
594
+                "schedule" => array(
595 595
                 "start_time" => "2016-10-17T07:04:59.731Z",
596 596
                 "stop_time" => "2016-10-17T07:04:59.731Z",
597 597
                 "time_zone" => "UTC"
598
-              ),
599
-              "status" => "active",
600
-              "variations" => array(
598
+                ),
599
+                "status" => "active",
600
+                "variations" => array(
601 601
                 array(
602
-                  "actions" => array(
602
+                    "actions" => array(
603 603
                     array(
604
-                      "changes" => array(
604
+                        "changes" => array(
605 605
                         array(
606
-                          "type" => "custom_code",
607
-                          "allow_additional_redirect" => true,
608
-                          "async" => true,
609
-                          "css_selector" => "a[href*=\"optimizely\"]",
610
-                          "dependencies" => array(
606
+                            "type" => "custom_code",
607
+                            "allow_additional_redirect" => true,
608
+                            "async" => true,
609
+                            "css_selector" => "a[href*=\"optimizely\"]",
610
+                            "dependencies" => array(
611 611
                             24,
612 612
                             26
613
-                          ),
614
-                          "destination" => "https://app.optimizely.com/",
615
-                          "extension_id" => 1234,
616
-                          "preserve_parameters" => true,
617
-                          "src" => 524,
618
-                          "value" => "window.someGlobalFunction();"
613
+                            ),
614
+                            "destination" => "https://app.optimizely.com/",
615
+                            "extension_id" => 1234,
616
+                            "preserve_parameters" => true,
617
+                            "src" => 524,
618
+                            "value" => "window.someGlobalFunction();"
619 619
                         )
620
-                      ),
621
-                      "page_id" => 0
620
+                        ),
621
+                        "page_id" => 0
622 622
                     )
623
-                  ),
624
-                  "archived" => true,
625
-                  "key" => "blue_button_variation",
626
-                  "name" => "Blue Button",
627
-                  "variation_id" => 0,
628
-                  "weight" => 0
623
+                    ),
624
+                    "archived" => true,
625
+                    "key" => "blue_button_variation",
626
+                    "name" => "Blue Button",
627
+                    "variation_id" => 0,
628
+                    "weight" => 0
629
+                )
629 630
                 )
630
-              )
631 631
         ));
632 632
         
633 633
         $result = $experimentsService->update(1000, $experiment, true, true);
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -109,9 +109,9 @@  discard block
 block discarded – undo
109 109
         $result = $experimentsService->listAll(1000);
110 110
         $experiments = $result->getPayload();
111 111
         
112
-        $this->assertTrue(count($experiments)==1);
112
+        $this->assertTrue(count($experiments) == 1);
113 113
         $this->assertTrue($experiments[0] instanceOf Experiment);
114
-        $this->assertTrue($experiments[0]->getName()=='Blue Button Experiment');        
114
+        $this->assertTrue($experiments[0]->getName() == 'Blue Button Experiment');        
115 115
     }
116 116
     
117 117
     /**
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
         $experiment = $result->getPayload();
256 256
         
257 257
         $this->assertTrue($experiment instanceOf Experiment);
258
-        $this->assertTrue($experiment->getName()=='Blue Button Experiment');        
258
+        $this->assertTrue($experiment->getName() == 'Blue Button Experiment');        
259 259
     }
260 260
     
261 261
     /**
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
         $experimentResults = $result->getPayload();
370 370
         
371 371
         $this->assertTrue($experimentResults instanceOf ExperimentResults);
372
-        $this->assertTrue($experimentResults->getConfidenceThreshold()==0.9);        
372
+        $this->assertTrue($experimentResults->getConfidenceThreshold() == 0.9);        
373 373
     }
374 374
     
375 375
     public function testCreate()
@@ -541,7 +541,7 @@  discard block
 block discarded – undo
541 541
         $createdExperiment = $result->getPayload();
542 542
         
543 543
         $this->assertTrue($createdExperiment instanceOf Experiment);
544
-        $this->assertTrue($createdExperiment->getName()=='Blue Button Experiment');                
544
+        $this->assertTrue($createdExperiment->getName() == 'Blue Button Experiment');                
545 545
     }
546 546
     
547 547
     public function testUpdate()
@@ -709,7 +709,7 @@  discard block
 block discarded – undo
709 709
         $updatedExperiment = $result->getPayload();
710 710
         
711 711
         $this->assertTrue($updatedExperiment instanceOf Experiment);
712
-        $this->assertTrue($updatedExperiment->getName()=='Blue Button Experiment');                
712
+        $this->assertTrue($updatedExperiment->getName() == 'Blue Button Experiment');                
713 713
     }
714 714
     
715 715
     public function testDelete()
Please login to merge, or discard this patch.
tests/OptimizelyPHPTest/Service/v2/PagesTest.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -42,9 +42,9 @@  discard block
 block discarded – undo
42 42
         $result = $pagesService->listAll(1000);
43 43
         $pages = $result->getPayload();
44 44
         
45
-        $this->assertTrue(count($pages)==1);
45
+        $this->assertTrue(count($pages) == 1);
46 46
         $this->assertTrue($pages[0] instanceOf Page);
47
-        $this->assertTrue($pages[0]->getName()=='Home Page');        
47
+        $this->assertTrue($pages[0]->getName() == 'Home Page');        
48 48
     }
49 49
     
50 50
     public function testGet()
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
         $createdPage = $result->getPayload();
128 128
         
129 129
         $this->assertTrue($createdPage instanceOf Page);
130
-        $this->assertTrue($createdPage->getName()=='Home Page');                
130
+        $this->assertTrue($createdPage->getName() == 'Home Page');                
131 131
     }
132 132
     
133 133
     public function testUpdate()
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
         $updatedPage = $result->getPayload();
176 176
         
177 177
         $this->assertTrue($updatedPage instanceOf Page);
178
-        $this->assertTrue($updatedPage->getName()=='Home Page');                  
178
+        $this->assertTrue($updatedPage->getName() == 'Home Page');                  
179 179
     }
180 180
     
181 181
     public function testDelete()
Please login to merge, or discard this patch.
examples/Projects/GetProjects.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -16,10 +16,10 @@  discard block
 block discarded – undo
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
 // Get OAuth 2.0 credentials from auth_credentials.json and access_token.json files.
25 25
 $credentials = load_credentials_from_file();
@@ -42,24 +42,24 @@  discard block
 block discarded – undo
42 42
         $projects = $result->getPayload();
43 43
         
44 44
         foreach ($projects as $project) {
45
-            echo "ID: " . $project->getId() . "\n";
46
-            echo "Name: " . $project->getName() . "\n";
47
-            echo "Account ID: " . $project->getAccountId() . "\n";
48
-            echo "Platform: " . $project->getPlatform() . "\n";
49
-            echo "Status: " . $project->getStatus() . "\n";
50
-            echo "Is Classic: " . ($project->getIsClassic()?"true":"false") . "\n";
51
-            echo "Created: " . $project->getCreated() . "\n";
52
-            echo "Last Modified: " . $project->getLastModified() . "\n";
45
+            echo "ID: ".$project->getId()."\n";
46
+            echo "Name: ".$project->getName()."\n";
47
+            echo "Account ID: ".$project->getAccountId()."\n";
48
+            echo "Platform: ".$project->getPlatform()."\n";
49
+            echo "Status: ".$project->getStatus()."\n";
50
+            echo "Is Classic: ".($project->getIsClassic() ? "true" : "false")."\n";
51
+            echo "Created: ".$project->getCreated()."\n";
52
+            echo "Last Modified: ".$project->getLastModified()."\n";
53 53
             
54 54
             echo "\n";
55 55
         }
56 56
         
57 57
         // Determine if there are more projects.
58
-        if ($result->getNextPage()==null)
58
+        if ($result->getNextPage() == null)
59 59
             break;
60 60
         
61 61
         // Increment page counter.
62
-        $page ++;
62
+        $page++;
63 63
     }
64 64
         
65 65
 } catch (Exception $e) {
@@ -73,6 +73,6 @@  discard block
 block discarded – undo
73 73
 
74 74
 // Save access token for later use
75 75
 $accessToken = $optimizelyClient->getAccessToken();
76
-file_put_contents(dirname(__FILE__) . '/../access_token.json', json_encode($accessToken));
76
+file_put_contents(dirname(__FILE__).'/../access_token.json', json_encode($accessToken));
77 77
 
78 78
 echo "Done!\n";
79 79
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -55,8 +55,9 @@
 block discarded – undo
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 ++;
Please login to merge, or discard this patch.
examples/Experiments/CreateExperiment.php 3 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -17,10 +17,10 @@  discard block
 block discarded – undo
17 17
 use WebMarketingROI\OptimizelyPHP\Resource\v2\Project;
18 18
 
19 19
 // Init class autloading.
20
-include dirname(__FILE__) . '/../../vendor/autoload.php';
20
+include dirname(__FILE__).'/../../vendor/autoload.php';
21 21
 
22 22
 // Include Utils.php - a file containing helper functions
23
-include dirname(__FILE__) . '/../Utils.php';
23
+include dirname(__FILE__).'/../Utils.php';
24 24
 
25 25
 // Get OAuth 2.0 credentials from auth_credentials.json and access_token.json files.
26 26
 $credentials = load_credentials_from_file();
@@ -117,6 +117,6 @@  discard block
 block discarded – undo
117 117
 
118 118
 // Save access token for later use
119 119
 $accessToken = $optimizelyClient->getAccessToken();
120
-file_put_contents(dirname(__FILE__) . '/../access_token.json', json_encode($accessToken));
120
+file_put_contents(dirname(__FILE__).'/../access_token.json', json_encode($accessToken));
121 121
 
122 122
 echo "Done!\n";
123 123
\ No newline at end of file
Please login to merge, or discard this patch.
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,6 @@
 block discarded – undo
14 14
 
15 15
 use WebMarketingROI\OptimizelyPHP\OptimizelyApiClient;
16 16
 use WebMarketingROI\OptimizelyPHP\Exception;
17
-use WebMarketingROI\OptimizelyPHP\Resource\v2\Project;
18 17
 
19 18
 // Init class autloading.
20 19
 include dirname(__FILE__) . '/../../vendor/autoload.php';
Please login to merge, or discard this patch.
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -33,73 +33,73 @@
 block discarded – undo
33 33
     $experiment = new Experiment(array(
34 34
             "project_id" => 1000,
35 35
             "audience_ids" => array(
36
-              1234,
37
-              1212,
38
-              1432
36
+                1234,
37
+                1212,
38
+                1432
39 39
             ),
40 40
             "campaign_id" => 2000,
41 41
             "changes" => array(
42
-              array(
42
+                array(
43 43
                 "type" => "custom_code",
44 44
                 "allow_additional_redirect" => true,
45 45
                 "async" => true,
46 46
                 "css_selector" => "a[href*=\"optimizely\"]",
47 47
                 "dependencies" => array(
48
-                  24,
49
-                  26
48
+                    24,
49
+                    26
50 50
                 ),
51 51
                 "destination" => "https://app.optimizely.com/",
52 52
                 "extension_id" => 1234,
53 53
                 "preserve_parameters" => true,
54 54
                 "src" => 524,
55 55
                 "value" => "window.someGlobalFunction();"
56
-              )
56
+                )
57 57
             ),
58 58
             "description" => "string",
59 59
             "holdback" => 5000,
60 60
             "key" => "home_page_experiment",
61 61
             "metrics" => array(
62
-              array(
62
+                array(
63 63
                 "kind" => "string"
64
-              )
64
+                )
65 65
             ),
66 66
             "name" => "Blue Button Experiment",
67 67
             "schedule" => array(
68
-              "start_time" => "2016-10-17T07:04:59.724Z",
69
-              "stop_time" => "2016-10-17T07:04:59.724Z",
70
-              "time_zone" => "UTC"
68
+                "start_time" => "2016-10-17T07:04:59.724Z",
69
+                "stop_time" => "2016-10-17T07:04:59.724Z",
70
+                "time_zone" => "UTC"
71 71
             ),
72 72
             "status" => "active",
73 73
             "variations" => array(
74
-              array(
74
+                array(
75 75
                 "actions" => array(
76
-                  array(
76
+                    array(
77 77
                     "changes" => array(
78
-                      array(
78
+                        array(
79 79
                         "type" => "custom_code",
80 80
                         "allow_additional_redirect" => true,
81 81
                         "async" => true,
82 82
                         "css_selector" => "a[href*=\"optimizely\"]",
83 83
                         "dependencies" => array(
84
-                          24,
85
-                          26
84
+                            24,
85
+                            26
86 86
                         ),
87 87
                         "destination" => "https://app.optimizely.com/",
88 88
                         "extension_id" => 1234,
89 89
                         "preserve_parameters" => true,
90 90
                         "src" => 524,
91 91
                         "value" => "window.someGlobalFunction();"
92
-                      )
92
+                        )
93 93
                     ),
94 94
                     "page_id" => 0
95
-                  )
95
+                    )
96 96
                 ),
97 97
                 "archived" => true,
98 98
                 "key" => "blue_button_variation",
99 99
                 "name" => "Blue Button",
100 100
                 "variation_id" => 0,
101 101
                 "weight" => 0
102
-              )
102
+                )
103 103
             )
104 104
         ));
105 105
         
Please login to merge, or discard this patch.
lib/WebMarketingROI/OptimizelyPHP/Service/v2/Events.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -38,14 +38,14 @@
 block discarded – undo
38 38
      * @return Result
39 39
      * @throws Exception
40 40
      */
41
-    public function listAll($projectId, $includeClassic, $page=1, $perPage=25)
41
+    public function listAll($projectId, $includeClassic, $page = 1, $perPage = 25)
42 42
     {
43
-        if ($page<0) {
43
+        if ($page < 0) {
44 44
             throw new Exception('Invalid page number passed',
45 45
                     Exception::CODE_INVALID_ARG);
46 46
         }
47 47
         
48
-        if ($perPage<0) {
48
+        if ($perPage < 0) {
49 49
             throw new Exception('Invalid page size passed',
50 50
                     Exception::CODE_INVALID_ARG);
51 51
         }
Please login to merge, or discard this patch.
lib/WebMarketingROI/OptimizelyPHP/Service/v2/Pages.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -36,13 +36,13 @@
 block discarded – undo
36 36
      * @return Result
37 37
      * @throws Exception
38 38
      */
39
-    public function listAll($projectId, $page=1, $perPage=25)
39
+    public function listAll($projectId, $page = 1, $perPage = 25)
40 40
     {
41
-        if ($page<0) {
41
+        if ($page < 0) {
42 42
             throw new Exception('Invalid page number passed');
43 43
         }
44 44
         
45
-        if ($perPage<0) {
45
+        if ($perPage < 0) {
46 46
             throw new Exception('Invalid page size passed');
47 47
         }
48 48
         
Please login to merge, or discard this patch.
lib/WebMarketingROI/OptimizelyPHP/Resource/v2/Change.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
                 case 'value': $this->setValue($value); break;
104 104
                 case 'id': $this->setId($value); break;
105 105
                 default:
106
-                    throw new Exception('Unknown option: ' . $name);
106
+                    throw new Exception('Unknown option: '.$name);
107 107
             }
108 108
         }
109 109
     }
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
         // Remove options with empty values
131 131
         $cleanedOptions = array();
132 132
         foreach ($options as $name=>$value) {
133
-            if ($value!==null)
133
+            if ($value !== null)
134 134
                 $cleanedOptions[$name] = $value;
135 135
         }
136 136
         
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -91,8 +91,9 @@
 block discarded – undo
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;
Please login to merge, or discard this patch.