@@ -8,9 +8,9 @@ discard block |
||
| 8 | 8 | public function loadCredentialsFromFile() |
| 9 | 9 | { |
| 10 | 10 | // Get OAuth 2.0 credentials from auth_credentials.json file. |
| 11 | - $credentials = file_get_contents(dirname(__FILE__) . '/../../../auth_credentials.json'); |
|
| 12 | - if ($credentials===false) { |
|
| 13 | - $this->fail("Couldn't read OAuth credentials from auth_credentials.json. Make sure " . |
|
| 11 | + $credentials = file_get_contents(dirname(__FILE__).'/../../../auth_credentials.json'); |
|
| 12 | + if ($credentials === false) { |
|
| 13 | + $this->fail("Couldn't read OAuth credentials from auth_credentials.json. Make sure ". |
|
| 14 | 14 | "the file exists (if not, copy from auth_credentials.json.dist)."); |
| 15 | 15 | } |
| 16 | 16 | |
@@ -20,8 +20,8 @@ discard block |
||
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | // Try to read access_token.json and merge it with the rest of credentials. |
| 23 | - if (is_readable(dirname(__FILE__) . '/../../../access_token.json')) { |
|
| 24 | - $accessToken = file_get_contents(dirname(__FILE__) . '/access_token.json'); |
|
| 23 | + if (is_readable(dirname(__FILE__).'/../../../access_token.json')) { |
|
| 24 | + $accessToken = file_get_contents(dirname(__FILE__).'/access_token.json'); |
|
| 25 | 25 | |
| 26 | 26 | $accessToken = json_decode($accessToken, true); |
| 27 | 27 | if (!is_array($accessToken)) { |
@@ -13,9 +13,9 @@ discard block |
||
| 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 |
||
| 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)) { |
@@ -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() |
@@ -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 |
@@ -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 |
@@ -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 | |
@@ -103,7 +103,7 @@ discard block |
||
| 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 |
||
| 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 | |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | case 'kind': $this->setKind($value); break; |
| 36 | 36 | case 'id': $this->setId($value); break; |
| 37 | 37 | default: |
| 38 | - throw new Exception('Unknown option: ' . $name); |
|
| 38 | + throw new Exception('Unknown option: '.$name); |
|
| 39 | 39 | } |
| 40 | 40 | } |
| 41 | 41 | } |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | // Remove options with empty values |
| 54 | 54 | $cleanedOptions = array(); |
| 55 | 55 | foreach ($options as $name=>$value) { |
| 56 | - if ($value!==null) |
|
| 56 | + if ($value !== null) |
|
| 57 | 57 | $cleanedOptions[$name] = $value; |
| 58 | 58 | } |
| 59 | 59 | |