@@ -82,7 +82,6 @@ discard block |
||
82 | 82 | |
83 | 83 | /** |
84 | 84 | * Set HTTP response code. |
85 | - * @param integer $code |
|
86 | 85 | */ |
87 | 86 | public function setHttpCode($httpCode) |
88 | 87 | { |
@@ -100,7 +99,6 @@ discard block |
||
100 | 99 | |
101 | 100 | /** |
102 | 101 | * Set message |
103 | - * @param string $message |
|
104 | 102 | */ |
105 | 103 | public function setUuid($uuid) |
106 | 104 | { |
@@ -55,20 +55,25 @@ |
||
55 | 55 | { |
56 | 56 | parent::__construct($message, $code); |
57 | 57 | |
58 | - if (isset($options['http_code'])) |
|
59 | - $this->setHttpCode($options['http_code']); |
|
58 | + if (isset($options['http_code'])) { |
|
59 | + $this->setHttpCode($options['http_code']); |
|
60 | + } |
|
60 | 61 | |
61 | - if (isset($options['uuid'])) |
|
62 | - $this->setUuid($options['uuid']); |
|
62 | + if (isset($options['uuid'])) { |
|
63 | + $this->setUuid($options['uuid']); |
|
64 | + } |
|
63 | 65 | |
64 | - if (isset($options['rate_limit'])) |
|
65 | - $this->setRateLimit($options['rate_limit']); |
|
66 | + if (isset($options['rate_limit'])) { |
|
67 | + $this->setRateLimit($options['rate_limit']); |
|
68 | + } |
|
66 | 69 | |
67 | - if (isset($options['rate_limit_remaining'])) |
|
68 | - $this->setRateLimitRemaining($options['rate_limit_remaining']); |
|
70 | + if (isset($options['rate_limit_remaining'])) { |
|
71 | + $this->setRateLimitRemaining($options['rate_limit_remaining']); |
|
72 | + } |
|
69 | 73 | |
70 | - if (isset($options['rate_limit_reset'])) |
|
71 | - $this->setRateLimitReset($options['rate_limit_reset']); |
|
74 | + if (isset($options['rate_limit_reset'])) { |
|
75 | + $this->setRateLimitReset($options['rate_limit_reset']); |
|
76 | + } |
|
72 | 77 | } |
73 | 78 | |
74 | 79 | /** |
@@ -163,7 +163,7 @@ discard block |
||
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 |
||
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', |
@@ -50,13 +50,13 @@ discard block |
||
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 |
||
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 |
||
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 array'); |
112 | 112 | } |
113 | 113 | |
@@ -166,16 +166,16 @@ discard block |
||
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 |
||
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,41 +199,41 @@ discard block |
||
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 | // Set HTTP options. |
234 | 234 | curl_setopt($this->curlHandle, CURLOPT_URL, $url); |
235 | 235 | curl_setopt($this->curlHandle, CURLOPT_CUSTOMREQUEST, $method); |
236 | - if (count($postData)!=0) { |
|
236 | + if (count($postData) != 0) { |
|
237 | 237 | curl_setopt($this->curlHandle, CURLOPT_POSTFIELDS, $content); |
238 | 238 | } |
239 | 239 | curl_setopt($this->curlHandle, CURLOPT_RETURNTRANSFER, true); |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | if ($result === false) { |
252 | 252 | $code = curl_errno($this->curlHandle); |
253 | 253 | $error = curl_error($this->curlHandle); |
254 | - throw new Exception("Failed to send HTTP request $method '$url', " . |
|
254 | + throw new Exception("Failed to send HTTP request $method '$url', ". |
|
255 | 255 | "the error code was $code, error message was: '$error'", |
256 | 256 | Exception::CODE_CURL_ERROR, $code, $error); |
257 | 257 | } |
@@ -265,12 +265,12 @@ discard block |
||
265 | 265 | $headers = explode("\n", $headers); |
266 | 266 | $parsedHeaders = array(); |
267 | 267 | foreach ($headers as $i=>$header) { |
268 | - if ($i==0) |
|
268 | + if ($i == 0) |
|
269 | 269 | continue; // Skip first line (http code). |
270 | 270 | $pos = strpos($header, ':'); |
271 | - if ($pos!=false) { |
|
271 | + if ($pos != false) { |
|
272 | 272 | $headerName = trim(strtolower(substr($header, 0, $pos))); |
273 | - $headerValue = trim(substr($header, $pos+1)); |
|
273 | + $headerValue = trim(substr($header, $pos + 1)); |
|
274 | 274 | $parsedHeaders[$headerName] = $headerValue; |
275 | 275 | } |
276 | 276 | } |
@@ -302,21 +302,21 @@ discard block |
||
302 | 302 | |
303 | 303 | // JSON-decode payload. |
304 | 304 | $decodedPayload = json_decode($body, true); |
305 | - if ($decodedPayload===false) { |
|
306 | - throw new Exception('Could not JSON-decode the Optimizely API response. Request was ' . |
|
307 | - $method . ' "' . $url . '". The response was: "' . $body . '"', |
|
305 | + if ($decodedPayload === false) { |
|
306 | + throw new Exception('Could not JSON-decode the Optimizely API response. Request was '. |
|
307 | + $method.' "'.$url.'". The response was: "'.$body.'"', |
|
308 | 308 | Exception::CODE_API_ERROR, array('http_code'=>$httpCode)); |
309 | 309 | } |
310 | 310 | |
311 | 311 | // Check HTTP response code. |
312 | - if ($httpCode<200 || $httpCode>299) { |
|
312 | + if ($httpCode < 200 || $httpCode > 299) { |
|
313 | 313 | |
314 | 314 | if (!isset($decodedPayload['message']) || |
315 | 315 | !isset($decodedPayload['code']) || |
316 | 316 | !isset($decodedPayload['uuid']) || |
317 | 317 | $httpCode != !isset($decodedPayload['code'])) { |
318 | - throw new Exception('Optimizely API responded with error code ' . $httpCode . |
|
319 | - ', but response format was unexpected. Request was ' . $method . ' "' . $url . '". Response was "' . $body . '"', |
|
318 | + throw new Exception('Optimizely API responded with error code '.$httpCode. |
|
319 | + ', but response format was unexpected. Request was '.$method.' "'.$url.'". Response was "'.$body.'"', |
|
320 | 320 | Exception::CODE_API_ERROR, array( |
321 | 321 | 'http_code' => $httpCode, |
322 | 322 | 'rate_limit' => $rateLimit, |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | $matched = preg_match_all('/<(.+)>;\s+rel=(\w+)(,|\z)/U', |
349 | 349 | $parsedHeaders['link'], $matches, PREG_SET_ORDER); |
350 | 350 | if (!$matched) { |
351 | - throw new Exception('Error parsing LINK header: ' . |
|
351 | + throw new Exception('Error parsing LINK header: '. |
|
352 | 352 | $parsedHeaders['link'], Exception::CODE_API_ERROR, $httpCode); |
353 | 353 | } |
354 | 354 | |
@@ -358,22 +358,22 @@ discard block |
||
358 | 358 | $rel = $match[2]; |
359 | 359 | |
360 | 360 | $matched = preg_match('/page=(\d+)/U', $url, $pageMatches); |
361 | - if (!$matched || count($pageMatches)!=2) { |
|
362 | - throw new Exception('Error extracting page argument while parsing LINK header: ' . |
|
361 | + if (!$matched || count($pageMatches) != 2) { |
|
362 | + throw new Exception('Error extracting page argument while parsing LINK header: '. |
|
363 | 363 | $parsedHeaders['link'], Exception::CODE_API_ERROR, |
364 | 364 | array('http_code'=>$httpCode)); |
365 | 365 | } |
366 | 366 | |
367 | 367 | $pageNumber = $pageMatches[1]; |
368 | 368 | |
369 | - if ($rel=='prev') { |
|
369 | + if ($rel == 'prev') { |
|
370 | 370 | $result->setPrevPage($pageNumber); |
371 | - } else if ($rel=='next') { |
|
371 | + } else if ($rel == 'next') { |
|
372 | 372 | $result->setNextPage($pageNumber); |
373 | - } else if ($rel=='last') { |
|
373 | + } else if ($rel == 'last') { |
|
374 | 374 | $result->setLastPage($pageNumber); |
375 | 375 | } else { |
376 | - throw new Exception('Unexpected rel argument while parsing LINK header: ' . |
|
376 | + throw new Exception('Unexpected rel argument while parsing LINK header: '. |
|
377 | 377 | $parsedHeaders['link'], Exception::CODE_API_ERROR, |
378 | 378 | array('http_code'=>$httpCode)); |
379 | 379 | } |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | */ |
392 | 392 | private function isAccessTokenExpired() |
393 | 393 | { |
394 | - if(!isset($this->authCredentials['access_token'])) { |
|
394 | + if (!isset($this->authCredentials['access_token'])) { |
|
395 | 395 | return true; // We do not have access token. |
396 | 396 | } |
397 | 397 | |
@@ -432,15 +432,15 @@ discard block |
||
432 | 432 | $clientSecret = $this->authCredentials['client_secret']; |
433 | 433 | $refreshToken = $this->authCredentials['refresh_token']; |
434 | 434 | |
435 | - $url = "https://app.optimizely.com/oauth2/token?refresh_token=$refreshToken" . |
|
435 | + $url = "https://app.optimizely.com/oauth2/token?refresh_token=$refreshToken". |
|
436 | 436 | "&client_id=$clientId&client_secret=$clientSecret&grant_type=refresh_token"; |
437 | 437 | |
438 | 438 | $response = $this->sendHttpRequest($url, array(), 'POST'); |
439 | 439 | $decodedJsonData = $response->getDecodedJsonData(); |
440 | 440 | |
441 | 441 | if (!isset($decodedJsonData['access_token'])) { |
442 | - throw new Exception('Not found access token in response. Request URL was "' . |
|
443 | - $url. '". Response was "' . print_r(json_encode($decodedJsonData), true). '"', |
|
442 | + throw new Exception('Not found access token in response. Request URL was "'. |
|
443 | + $url.'". Response was "'.print_r(json_encode($decodedJsonData), true).'"', |
|
444 | 444 | Exception::CODE_API_ERROR, $response->getHttpCode()); |
445 | 445 | } |
446 | 446 |
@@ -265,8 +265,10 @@ discard block |
||
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 |
||
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']; |
@@ -70,8 +70,6 @@ discard block |
||
70 | 70 | /** |
71 | 71 | * Constructor. |
72 | 72 | * @param array $decodedJsonData |
73 | - * @param string $rawHttpResponseData |
|
74 | - * @param array[string] $rawHttpResponseHeaders |
|
75 | 73 | */ |
76 | 74 | public function __construct($decodedJsonData, $httpCode) |
77 | 75 | { |
@@ -90,7 +88,6 @@ discard block |
||
90 | 88 | |
91 | 89 | /** |
92 | 90 | * Set HTTP response code. |
93 | - * @param integer $code |
|
94 | 91 | */ |
95 | 92 | public function setHttpCode($httpCode) |
96 | 93 | { |
@@ -23,20 +23,20 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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); |
@@ -42,9 +42,9 @@ discard block |
||
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 |
||
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 |
||
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() |
@@ -49,9 +49,9 @@ discard block |
||
49 | 49 | $result = $audiencesService->listAll(1000); |
50 | 50 | $audiences = $result->getPayload(); |
51 | 51 | |
52 | - $this->assertTrue(count($audiences)==1); |
|
52 | + $this->assertTrue(count($audiences) == 1); |
|
53 | 53 | $this->assertTrue($audiences[0] instanceOf Audience); |
54 | - $this->assertTrue($audiences[0]->getName()=='Spanish speaking San Franciscans'); |
|
54 | + $this->assertTrue($audiences[0]->getName() == 'Spanish speaking San Franciscans'); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | public function testGet() |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | $audience = $result->getPayload(); |
93 | 93 | |
94 | 94 | $this->assertTrue($audience instanceOf Audience); |
95 | - $this->assertTrue($audience->getName()=='Spanish speaking San Franciscans'); |
|
95 | + $this->assertTrue($audience->getName() == 'Spanish speaking San Franciscans'); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | public function testCreate() |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | $createdAudience = $result->getPayload(); |
153 | 153 | |
154 | 154 | $this->assertTrue($createdAudience instanceOf Audience); |
155 | - $this->assertTrue($createdAudience->getName()=='Spanish speaking San Franciscans'); |
|
155 | + $this->assertTrue($createdAudience->getName() == 'Spanish speaking San Franciscans'); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | public function testUpdate() |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | $createdAudience = $result->getPayload(); |
213 | 213 | |
214 | 214 | $this->assertTrue($createdAudience instanceOf Audience); |
215 | - $this->assertTrue($createdAudience->getName()=='Spanish speaking San Franciscans'); |
|
215 | + $this->assertTrue($createdAudience->getName() == 'Spanish speaking San Franciscans'); |
|
216 | 216 | } |
217 | 217 | } |
218 | 218 |
@@ -50,9 +50,9 @@ discard block |
||
50 | 50 | $result = $projectsService->listAll(); |
51 | 51 | $projects = $result->getPayload(); |
52 | 52 | |
53 | - $this->assertTrue(count($projects)==1); |
|
53 | + $this->assertTrue(count($projects) == 1); |
|
54 | 54 | $this->assertTrue($projects[0] instanceOf Project); |
55 | - $this->assertTrue($projects[0]->getName()=='Some Optimizely Project'); |
|
55 | + $this->assertTrue($projects[0]->getName() == 'Some Optimizely Project'); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | public function testGet() |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | $project = $result->getPayload(); |
96 | 96 | |
97 | 97 | $this->assertTrue($project instanceOf Project); |
98 | - $this->assertTrue($project->getName()=='Some Optimizely Project'); |
|
98 | + $this->assertTrue($project->getName() == 'Some Optimizely Project'); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | public function testCreate() |
@@ -160,8 +160,8 @@ discard block |
||
160 | 160 | $createdProject = $result->getPayload(); |
161 | 161 | |
162 | 162 | $this->assertTrue($createdProject instanceOf Project); |
163 | - $this->assertTrue($createdProject->getName()=='Test Project'); |
|
164 | - $this->assertTrue($createdProject->getAccountId()==12345); |
|
163 | + $this->assertTrue($createdProject->getName() == 'Test Project'); |
|
164 | + $this->assertTrue($createdProject->getAccountId() == 12345); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | public function testUpdate() |
@@ -225,8 +225,8 @@ discard block |
||
225 | 225 | $updatedProject = $result->getPayload(); |
226 | 226 | |
227 | 227 | $this->assertTrue($updatedProject instanceOf Project); |
228 | - $this->assertTrue($updatedProject->getName()=='Test Project'); |
|
229 | - $this->assertTrue($updatedProject->getAccountId()==12345); |
|
228 | + $this->assertTrue($updatedProject->getName() == 'Test Project'); |
|
229 | + $this->assertTrue($updatedProject->getAccountId() == 12345); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | public function testIntegration() |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | $credentials = $this->loadCredentialsFromFile(); |
238 | 238 | |
239 | 239 | $optimizelyClient = new OptimizelyApiClient($credentials, 'v2'); |
240 | - $this->assertTrue($optimizelyClient!=null); |
|
240 | + $this->assertTrue($optimizelyClient != null); |
|
241 | 241 | |
242 | 242 | // Create new project |
243 | 243 | $curDate = date('Y-m-d H:i:s'); |
@@ -277,17 +277,17 @@ discard block |
||
277 | 277 | $projects = $result->getPayload(); |
278 | 278 | |
279 | 279 | foreach ($projects as $project) { |
280 | - if ($project->getName()=="Test Project $curDate") { |
|
280 | + if ($project->getName() == "Test Project $curDate") { |
|
281 | 281 | $projectId = $project->getId(); |
282 | 282 | $found = true; |
283 | 283 | break; |
284 | 284 | } |
285 | 285 | } |
286 | 286 | |
287 | - if ($result->getNextPage()==null) |
|
287 | + if ($result->getNextPage() == null) |
|
288 | 288 | break; |
289 | 289 | |
290 | - $page ++; |
|
290 | + $page++; |
|
291 | 291 | } |
292 | 292 | |
293 | 293 | $this->assertTrue($projectFound); |
@@ -231,8 +231,9 @@ discard block |
||
231 | 231 | |
232 | 232 | public function testIntegration() |
233 | 233 | { |
234 | - if (!getenv('OPTIMIZELY_PHP_TEST_INTEGRATION')) |
|
235 | - $this->markTestSkipped('OPTIMIZELY_PHP_TEST_INTEGRATION env var is not set'); |
|
234 | + if (!getenv('OPTIMIZELY_PHP_TEST_INTEGRATION')) { |
|
235 | + $this->markTestSkipped('OPTIMIZELY_PHP_TEST_INTEGRATION env var is not set'); |
|
236 | + } |
|
236 | 237 | |
237 | 238 | $credentials = $this->loadCredentialsFromFile(); |
238 | 239 | |
@@ -284,8 +285,9 @@ discard block |
||
284 | 285 | } |
285 | 286 | } |
286 | 287 | |
287 | - if ($result->getNextPage()==null) |
|
288 | - break; |
|
288 | + if ($result->getNextPage()==null) { |
|
289 | + break; |
|
290 | + } |
|
289 | 291 | |
290 | 292 | $page ++; |
291 | 293 | } |
@@ -16,10 +16,10 @@ 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 | // 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 |
||
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 |
||
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 |
@@ -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 ++; |
@@ -17,14 +17,14 @@ discard block |
||
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 | // Read project ID from command line. |
26 | -if ($argc!=2) { |
|
27 | - die('Expected 1 command-line argument, while got ' . $argc-1); |
|
26 | +if ($argc != 2) { |
|
27 | + die('Expected 1 command-line argument, while got '.$argc - 1); |
|
28 | 28 | } |
29 | 29 | $projectId = $argv[1]; |
30 | 30 | |
@@ -56,6 +56,6 @@ discard block |
||
56 | 56 | |
57 | 57 | // Save access token for later use |
58 | 58 | $accessToken = $optimizelyClient->getAccessToken(); |
59 | -file_put_contents(dirname(__FILE__) . '/../access_token.json', json_encode($accessToken)); |
|
59 | +file_put_contents(dirname(__FILE__).'/../access_token.json', json_encode($accessToken)); |
|
60 | 60 | |
61 | 61 | echo "Done!\n"; |
62 | 62 | \ No newline at end of file |