@@ -36,13 +36,13 @@ |
||
| 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 | |
@@ -74,7 +74,7 @@ |
||
| 74 | 74 | case 'unit': $this->setUnit($value); break; |
| 75 | 75 | case 'variation_results': $this->setVariationResults($value); break; |
| 76 | 76 | default: |
| 77 | - throw new Exception('Unknown option: ' . $name); |
|
| 77 | + throw new Exception('Unknown option: '.$name); |
|
| 78 | 78 | } |
| 79 | 79 | } |
| 80 | 80 | } |
@@ -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 | /** |
@@ -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 | { |
@@ -145,7 +143,7 @@ discard block |
||
| 145 | 143 | |
| 146 | 144 | /** |
| 147 | 145 | * Return the exact time that your fresh new rate limit kicks in. |
| 148 | - * @return integer|null |
|
| 146 | + * @return string |
|
| 149 | 147 | */ |
| 150 | 148 | public function getRateLimitReset() |
| 151 | 149 | { |
@@ -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 | { |
@@ -108,7 +105,7 @@ discard block |
||
| 108 | 105 | |
| 109 | 106 | /** |
| 110 | 107 | * Set payload (parsed and wrapped response data). |
| 111 | - * @param mixed $payload |
|
| 108 | + * @param integer $payload |
|
| 112 | 109 | */ |
| 113 | 110 | public function setPayload($payload) |
| 114 | 111 | { |
@@ -225,7 +222,7 @@ discard block |
||
| 225 | 222 | |
| 226 | 223 | /** |
| 227 | 224 | * Return the exact time that your fresh new rate limit kicks in. |
| 228 | - * @return integer|null |
|
| 225 | + * @return string |
|
| 229 | 226 | */ |
| 230 | 227 | public function getRateLimitReset() |
| 231 | 228 | { |
@@ -176,16 +176,16 @@ discard block |
||
| 176 | 176 | "platform" => "web", |
| 177 | 177 | "status" => "active", |
| 178 | 178 | "web_snippet" => array( |
| 179 | - "enable_force_variation" => false, |
|
| 180 | - "exclude_disabled_experiments" => false, |
|
| 181 | - "exclude_names" => true, |
|
| 182 | - "include_jquery" => true, |
|
| 183 | - "ip_anonymization" => false, |
|
| 184 | - "ip_filter" => "^206\\.23\\.100\\.([5-9][0-9]|1([0-4][0-9]|50))$", |
|
| 185 | - "library" => "jquery-1.11.3-trim", |
|
| 186 | - "project_javascript" => "alert(\"Active Experiment\")", |
|
| 187 | - "code_revision" => 0, |
|
| 188 | - "js_file_size" => 63495 |
|
| 179 | + "enable_force_variation" => false, |
|
| 180 | + "exclude_disabled_experiments" => false, |
|
| 181 | + "exclude_names" => true, |
|
| 182 | + "include_jquery" => true, |
|
| 183 | + "ip_anonymization" => false, |
|
| 184 | + "ip_filter" => "^206\\.23\\.100\\.([5-9][0-9]|1([0-4][0-9]|50))$", |
|
| 185 | + "library" => "jquery-1.11.3-trim", |
|
| 186 | + "project_javascript" => "alert(\"Active Experiment\")", |
|
| 187 | + "code_revision" => 0, |
|
| 188 | + "js_file_size" => 63495 |
|
| 189 | 189 | ), |
| 190 | 190 | "created" => "2016-10-17T07:04:59.991Z", |
| 191 | 191 | "id" => 1000, |
@@ -206,14 +206,14 @@ discard block |
||
| 206 | 206 | "platform" => "web", |
| 207 | 207 | "status" => "active", |
| 208 | 208 | "web_snippet" => array( |
| 209 | - "enable_force_variation" => false, |
|
| 210 | - "exclude_disabled_experiments" => false, |
|
| 211 | - "exclude_names" => true, |
|
| 212 | - "include_jquery" => true, |
|
| 213 | - "ip_anonymization" => false, |
|
| 214 | - "ip_filter" => "^206\\.23\\.100\\.([5-9][0-9]|1([0-4][0-9]|50))$", |
|
| 215 | - "library" => "jquery-1.11.3-trim", |
|
| 216 | - "project_javascript" => "alert(\"Active Experiment\")" |
|
| 209 | + "enable_force_variation" => false, |
|
| 210 | + "exclude_disabled_experiments" => false, |
|
| 211 | + "exclude_names" => true, |
|
| 212 | + "include_jquery" => true, |
|
| 213 | + "ip_anonymization" => false, |
|
| 214 | + "ip_filter" => "^206\\.23\\.100\\.([5-9][0-9]|1([0-4][0-9]|50))$", |
|
| 215 | + "library" => "jquery-1.11.3-trim", |
|
| 216 | + "project_javascript" => "alert(\"Active Experiment\")" |
|
| 217 | 217 | ) |
| 218 | 218 | )); |
| 219 | 219 | |
@@ -257,16 +257,16 @@ discard block |
||
| 257 | 257 | "platform" => "web", |
| 258 | 258 | "status" => "active", |
| 259 | 259 | "web_snippet" => array( |
| 260 | - "enable_force_variation" => false, |
|
| 261 | - "exclude_disabled_experiments" => false, |
|
| 262 | - "exclude_names" => true, |
|
| 263 | - "include_jquery" => true, |
|
| 264 | - "ip_anonymization" => false, |
|
| 265 | - "ip_filter" => "^206\\.23\\.100\\.([5-9][0-9]|1([0-4][0-9]|50))$", |
|
| 266 | - "library" => "jquery-1.11.3-trim", |
|
| 267 | - "project_javascript" => "alert(\"Active Experiment\")", |
|
| 268 | - "code_revision" => 0, |
|
| 269 | - "js_file_size" => 63495 |
|
| 260 | + "enable_force_variation" => false, |
|
| 261 | + "exclude_disabled_experiments" => false, |
|
| 262 | + "exclude_names" => true, |
|
| 263 | + "include_jquery" => true, |
|
| 264 | + "ip_anonymization" => false, |
|
| 265 | + "ip_filter" => "^206\\.23\\.100\\.([5-9][0-9]|1([0-4][0-9]|50))$", |
|
| 266 | + "library" => "jquery-1.11.3-trim", |
|
| 267 | + "project_javascript" => "alert(\"Active Experiment\")", |
|
| 268 | + "code_revision" => 0, |
|
| 269 | + "js_file_size" => 63495 |
|
| 270 | 270 | ), |
| 271 | 271 | "created" => "2016-10-17T07:04:59.999Z", |
| 272 | 272 | "id" => 1000, |
@@ -286,14 +286,14 @@ discard block |
||
| 286 | 286 | "name" => "Test Project", |
| 287 | 287 | "status" => "active", |
| 288 | 288 | "web_snippet" => array( |
| 289 | - "enable_force_variation" => false, |
|
| 290 | - "exclude_disabled_experiments" => false, |
|
| 291 | - "exclude_names" => true, |
|
| 292 | - "include_jquery" => true, |
|
| 293 | - "ip_anonymization" => false, |
|
| 294 | - "ip_filter" => "^206\\.23\\.100\\.([5-9][0-9]|1([0-4][0-9]|50))$", |
|
| 295 | - "library" => "jquery-1.11.3-trim", |
|
| 296 | - "project_javascript" => "alert(\"Active Experiment\")" |
|
| 289 | + "enable_force_variation" => false, |
|
| 290 | + "exclude_disabled_experiments" => false, |
|
| 291 | + "exclude_names" => true, |
|
| 292 | + "include_jquery" => true, |
|
| 293 | + "ip_anonymization" => false, |
|
| 294 | + "ip_filter" => "^206\\.23\\.100\\.([5-9][0-9]|1([0-4][0-9]|50))$", |
|
| 295 | + "library" => "jquery-1.11.3-trim", |
|
| 296 | + "project_javascript" => "alert(\"Active Experiment\")" |
|
| 297 | 297 | ) |
| 298 | 298 | )); |
| 299 | 299 | |
@@ -51,9 +51,9 @@ discard block |
||
| 51 | 51 | $result = $projectsService->listAll(); |
| 52 | 52 | $projects = $result->getPayload(); |
| 53 | 53 | |
| 54 | - $this->assertTrue(count($projects)==1); |
|
| 54 | + $this->assertTrue(count($projects) == 1); |
|
| 55 | 55 | $this->assertTrue($projects[0] instanceOf Project); |
| 56 | - $this->assertTrue($projects[0]->getName()=='Some Optimizely Project'); |
|
| 56 | + $this->assertTrue($projects[0]->getName() == 'Some Optimizely Project'); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | /** |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | $project = $result->getPayload(); |
| 127 | 127 | |
| 128 | 128 | $this->assertTrue($project instanceOf Project); |
| 129 | - $this->assertTrue($project->getName()=='Some Optimizely Project'); |
|
| 129 | + $this->assertTrue($project->getName() == 'Some Optimizely Project'); |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | /** |
@@ -221,8 +221,8 @@ discard block |
||
| 221 | 221 | $createdProject = $result->getPayload(); |
| 222 | 222 | |
| 223 | 223 | $this->assertTrue($createdProject instanceOf Project); |
| 224 | - $this->assertTrue($createdProject->getName()=='Test Project'); |
|
| 225 | - $this->assertTrue($createdProject->getAccountId()==12345); |
|
| 224 | + $this->assertTrue($createdProject->getName() == 'Test Project'); |
|
| 225 | + $this->assertTrue($createdProject->getAccountId() == 12345); |
|
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | /** |
@@ -301,8 +301,8 @@ discard block |
||
| 301 | 301 | $updatedProject = $result->getPayload(); |
| 302 | 302 | |
| 303 | 303 | $this->assertTrue($updatedProject instanceOf Project); |
| 304 | - $this->assertTrue($updatedProject->getName()=='Test Project'); |
|
| 305 | - $this->assertTrue($updatedProject->getAccountId()==12345); |
|
| 304 | + $this->assertTrue($updatedProject->getName() == 'Test Project'); |
|
| 305 | + $this->assertTrue($updatedProject->getAccountId() == 12345); |
|
| 306 | 306 | } |
| 307 | 307 | |
| 308 | 308 | /** |
@@ -362,7 +362,7 @@ discard block |
||
| 362 | 362 | $credentials = $this->loadCredentialsFromFile(); |
| 363 | 363 | |
| 364 | 364 | $optimizelyClient = new OptimizelyApiClient($credentials, 'v2'); |
| 365 | - $this->assertTrue($optimizelyClient!=null); |
|
| 365 | + $this->assertTrue($optimizelyClient != null); |
|
| 366 | 366 | |
| 367 | 367 | $curDate = date('Y-m-d H:i:s'); |
| 368 | 368 | /*// Create new project |
@@ -408,17 +408,17 @@ discard block |
||
| 408 | 408 | $projects = $result->getPayload(); |
| 409 | 409 | |
| 410 | 410 | foreach ($projects as $project) { |
| 411 | - if ($project->getName()=="Test Project $curDate") { |
|
| 411 | + if ($project->getName() == "Test Project $curDate") { |
|
| 412 | 412 | $projectId = $project->getId(); |
| 413 | 413 | $found = true; |
| 414 | 414 | break; |
| 415 | 415 | } |
| 416 | 416 | } |
| 417 | 417 | |
| 418 | - if ($result->getNextPage()==null) |
|
| 418 | + if ($result->getNextPage() == null) |
|
| 419 | 419 | break; |
| 420 | 420 | |
| 421 | - $page ++; |
|
| 421 | + $page++; |
|
| 422 | 422 | } |
| 423 | 423 | } |
| 424 | 424 | catch (Exception $e) { |
@@ -437,13 +437,13 @@ discard block |
||
| 437 | 437 | try { |
| 438 | 438 | $result = $optimizelyClient->projects()->get(12345678); |
| 439 | 439 | } |
| 440 | - catch(Exception $e) { |
|
| 440 | + catch (Exception $e) { |
|
| 441 | 441 | $this->assertEquals(Exception::CODE_API_ERROR, $e->getCode()); |
| 442 | 442 | $this->assertEquals(400, $e->getHttpCode()); |
| 443 | - $this->assertTrue(strlen($e->getUuid())!=0); |
|
| 444 | - $this->assertTrue($e->getRateLimit()>0); |
|
| 445 | - $this->assertTrue($e->getRateLimitRemaining()>0); |
|
| 446 | - $this->assertTrue($e->getRateLimitReset()>0); |
|
| 443 | + $this->assertTrue(strlen($e->getUuid()) != 0); |
|
| 444 | + $this->assertTrue($e->getRateLimit() > 0); |
|
| 445 | + $this->assertTrue($e->getRateLimitRemaining() > 0); |
|
| 446 | + $this->assertTrue($e->getRateLimitReset() > 0); |
|
| 447 | 447 | } |
| 448 | 448 | |
| 449 | 449 | // Retrieve existing project by ID |
@@ -356,8 +356,9 @@ discard block |
||
| 356 | 356 | |
| 357 | 357 | public function testIntegration() |
| 358 | 358 | { |
| 359 | - if (!getenv('OPTIMIZELY_PHP_TEST_INTEGRATION')) |
|
| 360 | - $this->markTestSkipped('OPTIMIZELY_PHP_TEST_INTEGRATION env var is not set'); |
|
| 359 | + if (!getenv('OPTIMIZELY_PHP_TEST_INTEGRATION')) { |
|
| 360 | + $this->markTestSkipped('OPTIMIZELY_PHP_TEST_INTEGRATION env var is not set'); |
|
| 361 | + } |
|
| 361 | 362 | |
| 362 | 363 | $credentials = $this->loadCredentialsFromFile(); |
| 363 | 364 | |
@@ -415,13 +416,13 @@ discard block |
||
| 415 | 416 | } |
| 416 | 417 | } |
| 417 | 418 | |
| 418 | - if ($result->getNextPage()==null) |
|
| 419 | - break; |
|
| 419 | + if ($result->getNextPage()==null) { |
|
| 420 | + break; |
|
| 421 | + } |
|
| 420 | 422 | |
| 421 | 423 | $page ++; |
| 422 | 424 | } |
| 423 | - } |
|
| 424 | - catch (Exception $e) { |
|
| 425 | + } catch (Exception $e) { |
|
| 425 | 426 | print_r($optimizelyClient->getDiagnosticsInfo()); |
| 426 | 427 | // Handle error. |
| 427 | 428 | $code = $e->getCode(); |
@@ -436,8 +437,7 @@ discard block |
||
| 436 | 437 | // Try a non-existing project by ID - assume failure |
| 437 | 438 | try { |
| 438 | 439 | $result = $optimizelyClient->projects()->get(12345678); |
| 439 | - } |
|
| 440 | - catch(Exception $e) { |
|
| 440 | + } catch(Exception $e) { |
|
| 441 | 441 | $this->assertEquals(Exception::CODE_API_ERROR, $e->getCode()); |
| 442 | 442 | $this->assertEquals(400, $e->getHttpCode()); |
| 443 | 443 | $this->assertTrue(strlen($e->getUuid())!=0); |
@@ -163,8 +163,7 @@ |
||
| 163 | 163 | // refresh token, since the provided access token is invalid. |
| 164 | 164 | try { |
| 165 | 165 | $result = $client->sendApiRequest('/projects'); |
| 166 | - } |
|
| 167 | - catch (Exception $e) { |
|
| 166 | + } catch (Exception $e) { |
|
| 168 | 167 | $this->assertEquals(Exception::CODE_API_ERROR, $e->getCode()); |
| 169 | 168 | $this->assertEquals(400, $e->getHttpCode()); |
| 170 | 169 | } |
@@ -16,14 +16,14 @@ |
||
| 16 | 16 | "platform" => "web", |
| 17 | 17 | "status" => "active", |
| 18 | 18 | "web_snippet" => array( |
| 19 | - "enable_force_variation" => false, |
|
| 20 | - "exclude_disabled_experiments" => false, |
|
| 21 | - "exclude_names" => true, |
|
| 22 | - "include_jquery" => true, |
|
| 23 | - "ip_anonymization" => false, |
|
| 24 | - "ip_filter" => "^206\\.23\\.100\\.([5-9][0-9]|1([0-4][0-9]|50))$", |
|
| 25 | - "library" => "jquery-1.11.3-trim", |
|
| 26 | - "project_javascript" => "alert(\"Active Experiment\")" |
|
| 19 | + "enable_force_variation" => false, |
|
| 20 | + "exclude_disabled_experiments" => false, |
|
| 21 | + "exclude_names" => true, |
|
| 22 | + "include_jquery" => true, |
|
| 23 | + "ip_anonymization" => false, |
|
| 24 | + "ip_filter" => "^206\\.23\\.100\\.([5-9][0-9]|1([0-4][0-9]|50))$", |
|
| 25 | + "library" => "jquery-1.11.3-trim", |
|
| 26 | + "project_javascript" => "alert(\"Active Experiment\")" |
|
| 27 | 27 | )); |
| 28 | 28 | |
| 29 | 29 | $result = new Result($data, 200); |
@@ -36,13 +36,13 @@ |
||
| 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 || $perPage>100) { |
|
| 45 | + if ($perPage < 0 || $perPage > 100) { |
|
| 46 | 46 | throw new Exception('Invalid page size passed'); |
| 47 | 47 | } |
| 48 | 48 | |
@@ -39,17 +39,17 @@ discard block |
||
| 39 | 39 | * @return Result |
| 40 | 40 | * @throws Exception |
| 41 | 41 | */ |
| 42 | - public function listAll($projectId, $campaignId=null, $includeClassic=false, $page=1, $perPage=25) |
|
| 42 | + public function listAll($projectId, $campaignId = null, $includeClassic = false, $page = 1, $perPage = 25) |
|
| 43 | 43 | { |
| 44 | - if ($projectId==null && $campaignId==null) { |
|
| 44 | + if ($projectId == null && $campaignId == null) { |
|
| 45 | 45 | throw new Exception('Project ID or Campaign ID must be non-null'); |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - if ($page<0) { |
|
| 48 | + if ($page < 0) { |
|
| 49 | 49 | throw new Exception('Invalid page number passed'); |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - if ($perPage<0 || $perPage>100) { |
|
| 52 | + if ($perPage < 0 || $perPage > 100) { |
|
| 53 | 53 | throw new Exception('Invalid page size passed'); |
| 54 | 54 | } |
| 55 | 55 | |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | Exception::CODE_INVALID_ARG); |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - if ($experimentId<0) { |
|
| 88 | + if ($experimentId < 0) { |
|
| 89 | 89 | throw new Exception("A positive experiment ID expected"); |
| 90 | 90 | } |
| 91 | 91 | |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | throw new Exception("Expected argument of type Experiment"); |
| 176 | 176 | } |
| 177 | 177 | |
| 178 | - if ($experimentId<0) { |
|
| 178 | + if ($experimentId < 0) { |
|
| 179 | 179 | throw new Exception("Expected positive experiment ID argument"); |
| 180 | 180 | } |
| 181 | 181 | |