@@ -38,14 +38,14 @@ |
||
| 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 | } |
@@ -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 | |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | break; |
| 72 | 72 | } |
| 73 | 73 | default: |
| 74 | - throw new Exception('Unknown option: ' . $name); |
|
| 74 | + throw new Exception('Unknown option: '.$name); |
|
| 75 | 75 | } |
| 76 | 76 | } |
| 77 | 77 | } |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | // Remove options with empty values |
| 98 | 98 | $cleanedOptions = array(); |
| 99 | 99 | foreach ($options as $name=>$value) { |
| 100 | - if ($value!==null) |
|
| 100 | + if ($value !== null) |
|
| 101 | 101 | $cleanedOptions[$name] = $value; |
| 102 | 102 | } |
| 103 | 103 | |
@@ -91,8 +91,9 @@ |
||
| 91 | 91 | // Remove options with empty values |
| 92 | 92 | $cleanedOptions = array(); |
| 93 | 93 | foreach ($options as $name=>$value) { |
| 94 | - if ($value!==null) |
|
| 95 | - $cleanedOptions[$name] = $value; |
|
| 94 | + if ($value!==null) { |
|
| 95 | + $cleanedOptions[$name] = $value; |
|
| 96 | + } |
|
| 96 | 97 | } |
| 97 | 98 | |
| 98 | 99 | return $cleanedOptions; |
@@ -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 | { |
@@ -17,10 +17,10 @@ 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 | // 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 |
||
| 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 |
@@ -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 | { |
@@ -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 | |