@@ -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)) { |
@@ -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 |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | } |
89 | 89 | case 'unit': $this->setUnit($value); break; |
90 | 90 | default: |
91 | - throw new Exception('Unknown option: ' . $name); |
|
91 | + throw new Exception('Unknown option: '.$name); |
|
92 | 92 | } |
93 | 93 | } |
94 | 94 | } |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | // Remove options with empty values |
116 | 116 | $cleanedOptions = array(); |
117 | 117 | foreach ($options as $name=>$value) { |
118 | - if ($value!==null) |
|
118 | + if ($value !== null) |
|
119 | 119 | $cleanedOptions[$name] = $value; |
120 | 120 | } |
121 | 121 |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | case 'code_revision': $this->setCodeRevision($value); break; |
99 | 99 | case 'js_file_size': $this->setJsFileSize($value); break; |
100 | 100 | default: |
101 | - throw new Exception('Unknown option: ' . $name); |
|
101 | + throw new Exception('Unknown option: '.$name); |
|
102 | 102 | } |
103 | 103 | } |
104 | 104 | } |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | // Remove options with empty values |
125 | 125 | $cleanedOptions = array(); |
126 | 126 | foreach ($options as $name=>$value) { |
127 | - if ($value!==null) |
|
127 | + if ($value !== null) |
|
128 | 128 | $cleanedOptions[$name] = $value; |
129 | 129 | } |
130 | 130 |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | case 'stop_time': $this->setStopTime($value); break; |
43 | 43 | case 'time_zone': $this->setTimezone($value); break; |
44 | 44 | default: |
45 | - throw new Exception('Unknown option: ' . $name); |
|
45 | + throw new Exception('Unknown option: '.$name); |
|
46 | 46 | } |
47 | 47 | } |
48 | 48 | } |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | // Remove options with empty values |
62 | 62 | $cleanedOptions = array(); |
63 | 63 | foreach ($options as $name=>$value) { |
64 | - if ($value!==null) |
|
64 | + if ($value !== null) |
|
65 | 65 | $cleanedOptions[$name] = $value; |
66 | 66 | } |
67 | 67 |