@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | -if ( !class_exists('Puc_v4p4_Vcs_Reference', false) ): |
|
2 | +if (!class_exists('Puc_v4p4_Vcs_Reference', false)): |
|
3 | 3 | |
4 | 4 | /** |
5 | 5 | * This class represents a VCS branch or tag. It's intended as a read only, short-lived container |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if ( !class_exists('Puc_v4p4_Vcs_GitLabApi', false) ): |
|
3 | +if (!class_exists('Puc_v4p4_Vcs_GitLabApi', false)): |
|
4 | 4 | |
5 | 5 | class Puc_v4p4_Vcs_GitLabApi extends Puc_v4p4_Vcs_Api { |
6 | 6 | /** |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | |
30 | 30 | //Find the repository information |
31 | 31 | $path = @parse_url($repositoryUrl, PHP_URL_PATH); |
32 | - if ( preg_match('@^/?(?P<username>[^/]+?)/(?P<repository>[^/#?&]+?)/?$@', $path, $matches) ) { |
|
32 | + if (preg_match('@^/?(?P<username>[^/]+?)/(?P<repository>[^/#?&]+?)/?$@', $path, $matches)) { |
|
33 | 33 | $this->userName = $matches['username']; |
34 | 34 | $this->repositoryName = $matches['repository']; |
35 | 35 | } else { |
@@ -38,8 +38,8 @@ discard block |
||
38 | 38 | $segments = explode('/', untrailingslashit(ltrim($path, '/'))); |
39 | 39 | |
40 | 40 | //We need at least /user-name/repository-name/ |
41 | - if ( count($segments) < 2 ) { |
|
42 | - throw new InvalidArgumentException('Invalid GitLab repository URL: "' . $repositoryUrl . '"'); |
|
41 | + if (count($segments) < 2) { |
|
42 | + throw new InvalidArgumentException('Invalid GitLab repository URL: "'.$repositoryUrl.'"'); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | //Get the username and repository name. |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | $this->repositoryName = $usernameRepo[1]; |
49 | 49 | |
50 | 50 | //Append the remaining segments to the host. |
51 | - $this->repositoryHost = trailingslashit($this->repositoryHost) . implode('/', $segments); |
|
51 | + $this->repositoryHost = trailingslashit($this->repositoryHost).implode('/', $segments); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | parent::__construct($repositoryUrl, $accessToken); |
@@ -70,12 +70,12 @@ discard block |
||
70 | 70 | */ |
71 | 71 | public function getLatestTag() { |
72 | 72 | $tags = $this->api('/:user/:repo/repository/tags'); |
73 | - if ( is_wp_error($tags) || empty($tags) || !is_array($tags) ) { |
|
73 | + if (is_wp_error($tags) || empty($tags) || !is_array($tags)) { |
|
74 | 74 | return null; |
75 | 75 | } |
76 | 76 | |
77 | 77 | $versionTags = $this->sortTagsByVersion($tags); |
78 | - if ( empty($versionTags) ) { |
|
78 | + if (empty($versionTags)) { |
|
79 | 79 | return null; |
80 | 80 | } |
81 | 81 | |
@@ -95,8 +95,8 @@ discard block |
||
95 | 95 | * @return null|Puc_v4p4_Vcs_Reference |
96 | 96 | */ |
97 | 97 | public function getBranch($branchName) { |
98 | - $branch = $this->api('/:user/:repo/repository/branches/' . $branchName); |
|
99 | - if ( is_wp_error($branch) || empty($branch) ) { |
|
98 | + $branch = $this->api('/:user/:repo/repository/branches/'.$branchName); |
|
99 | + if (is_wp_error($branch) || empty($branch)) { |
|
100 | 100 | return null; |
101 | 101 | } |
102 | 102 | |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | 'apiResponse' => $branch, |
107 | 107 | )); |
108 | 108 | |
109 | - if ( isset($branch->commit, $branch->commit->committed_date) ) { |
|
109 | + if (isset($branch->commit, $branch->commit->committed_date)) { |
|
110 | 110 | $reference->updated = $branch->commit->committed_date; |
111 | 111 | } |
112 | 112 | |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | */ |
122 | 122 | public function getLatestCommitTime($ref) { |
123 | 123 | $commits = $this->api('/:user/:repo/repository/commits/', array('ref_name' => $ref)); |
124 | - if ( is_wp_error($commits) || !is_array($commits) || !isset($commits[0]) ) { |
|
124 | + if (is_wp_error($commits) || !is_array($commits) || !isset($commits[0])) { |
|
125 | 125 | return null; |
126 | 126 | } |
127 | 127 | |
@@ -140,19 +140,19 @@ discard block |
||
140 | 140 | $url = $this->buildApiUrl($url, $queryParams); |
141 | 141 | |
142 | 142 | $options = array('timeout' => 10); |
143 | - if ( !empty($this->httpFilterName) ) { |
|
143 | + if (!empty($this->httpFilterName)) { |
|
144 | 144 | $options = apply_filters($this->httpFilterName, $options); |
145 | 145 | } |
146 | 146 | |
147 | 147 | $response = wp_remote_get($url, $options); |
148 | - if ( is_wp_error($response) ) { |
|
148 | + if (is_wp_error($response)) { |
|
149 | 149 | do_action('puc_api_error', $response, null, $url, $this->slug); |
150 | 150 | return $response; |
151 | 151 | } |
152 | 152 | |
153 | 153 | $code = wp_remote_retrieve_response_code($response); |
154 | 154 | $body = wp_remote_retrieve_body($response); |
155 | - if ( $code === 200 ) { |
|
155 | + if ($code === 200) { |
|
156 | 156 | return json_decode($body); |
157 | 157 | } |
158 | 158 | |
@@ -179,17 +179,17 @@ discard block |
||
179 | 179 | ); |
180 | 180 | |
181 | 181 | foreach ($variables as $name => $value) { |
182 | - $url = str_replace("/:{$name}", urlencode('/' . $value), $url); |
|
182 | + $url = str_replace("/:{$name}", urlencode('/'.$value), $url); |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | $url = substr($url, 3); |
186 | 186 | $url = sprintf('https://%1$s/api/v4/projects/%2$s', $this->repositoryHost, $url); |
187 | 187 | |
188 | - if ( !empty($this->accessToken) ) { |
|
188 | + if (!empty($this->accessToken)) { |
|
189 | 189 | $queryParams['private_token'] = $this->accessToken; |
190 | 190 | } |
191 | 191 | |
192 | - if ( !empty($queryParams) ) { |
|
192 | + if (!empty($queryParams)) { |
|
193 | 193 | $url = add_query_arg($queryParams, $url); |
194 | 194 | } |
195 | 195 | |
@@ -204,8 +204,8 @@ discard block |
||
204 | 204 | * @return null|string Either the contents of the file, or null if the file doesn't exist or there's an error. |
205 | 205 | */ |
206 | 206 | public function getRemoteFile($path, $ref = 'master') { |
207 | - $response = $this->api('/:user/:repo/repository/files/' . $path, array('ref' => $ref)); |
|
208 | - if ( is_wp_error($response) || !isset($response->content) || $response->encoding !== 'base64' ) { |
|
207 | + $response = $this->api('/:user/:repo/repository/files/'.$path, array('ref' => $ref)); |
|
208 | + if (is_wp_error($response) || !isset($response->content) || $response->encoding !== 'base64') { |
|
209 | 209 | return null; |
210 | 210 | } |
211 | 211 | |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | urlencode($ref) |
228 | 228 | ); |
229 | 229 | |
230 | - if ( !empty($this->accessToken) ) { |
|
230 | + if (!empty($this->accessToken)) { |
|
231 | 231 | $url = add_query_arg('private_token', $this->accessToken, $url); |
232 | 232 | } |
233 | 233 | |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | * @return Puc_v4p4_Vcs_Reference|null |
242 | 242 | */ |
243 | 243 | public function getTag($tagName) { |
244 | - throw new LogicException('The ' . __METHOD__ . ' method is not implemented and should not be used.'); |
|
244 | + throw new LogicException('The '.__METHOD__.' method is not implemented and should not be used.'); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | /** |
@@ -254,11 +254,11 @@ discard block |
||
254 | 254 | $updateSource = null; |
255 | 255 | |
256 | 256 | // GitLab doesn't handle releases the same as GitHub so just use the latest tag |
257 | - if ( $configBranch === 'master' ) { |
|
257 | + if ($configBranch === 'master') { |
|
258 | 258 | $updateSource = $this->getLatestTag(); |
259 | 259 | } |
260 | 260 | |
261 | - if ( empty($updateSource) ) { |
|
261 | + if (empty($updateSource)) { |
|
262 | 262 | $updateSource = $this->getBranch($configBranch); |
263 | 263 | } |
264 | 264 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( !class_exists('Puc_v4p4_Vcs_Api') ): |
|
2 | +if (!class_exists('Puc_v4p4_Vcs_Api')): |
|
3 | 3 | |
4 | 4 | abstract class Puc_v4p4_Vcs_Api { |
5 | 5 | protected $tagNameProperty = 'name'; |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | */ |
62 | 62 | public function getRemoteReadme($ref = 'master') { |
63 | 63 | $fileContents = $this->getRemoteFile($this->getLocalReadmeName(), $ref); |
64 | - if ( empty($fileContents) ) { |
|
64 | + if (empty($fileContents)) { |
|
65 | 65 | return array(); |
66 | 66 | } |
67 | 67 | |
@@ -82,16 +82,16 @@ discard block |
||
82 | 82 | */ |
83 | 83 | public function getLocalReadmeName() { |
84 | 84 | static $fileName = null; |
85 | - if ( $fileName !== null ) { |
|
85 | + if ($fileName !== null) { |
|
86 | 86 | return $fileName; |
87 | 87 | } |
88 | 88 | |
89 | 89 | $fileName = 'readme.txt'; |
90 | - if ( isset($this->localDirectory) ) { |
|
90 | + if (isset($this->localDirectory)) { |
|
91 | 91 | $files = scandir($this->localDirectory); |
92 | - if ( !empty($files) ) { |
|
92 | + if (!empty($files)) { |
|
93 | 93 | foreach ($files as $possibleFileName) { |
94 | - if ( strcasecmp($possibleFileName, 'readme.txt') === 0 ) { |
|
94 | + if (strcasecmp($possibleFileName, 'readme.txt') === 0) { |
|
95 | 95 | $fileName = $possibleFileName; |
96 | 96 | break; |
97 | 97 | } |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | $name = ltrim($name, 'v'); |
137 | 137 | |
138 | 138 | //The version string must start with a number. |
139 | - if ( !is_numeric(substr($name, 0, 1)) ) { |
|
139 | + if (!is_numeric(substr($name, 0, 1))) { |
|
140 | 140 | return false; |
141 | 141 | } |
142 | 142 | |
@@ -180,10 +180,10 @@ discard block |
||
180 | 180 | */ |
181 | 181 | protected function compareTagNames($tag1, $tag2) { |
182 | 182 | $property = $this->tagNameProperty; |
183 | - if ( !isset($tag1->$property) ) { |
|
183 | + if (!isset($tag1->$property)) { |
|
184 | 184 | return 1; |
185 | 185 | } |
186 | - if ( !isset($tag2->$property) ) { |
|
186 | + if (!isset($tag2->$property)) { |
|
187 | 187 | return -1; |
188 | 188 | } |
189 | 189 | return -version_compare(ltrim($tag1->$property, 'v'), ltrim($tag2->$property, 'v')); |
@@ -215,12 +215,12 @@ discard block |
||
215 | 215 | */ |
216 | 216 | public function getRemoteChangelog($ref, $localDirectory) { |
217 | 217 | $filename = $this->findChangelogName($localDirectory); |
218 | - if ( empty($filename) ) { |
|
218 | + if (empty($filename)) { |
|
219 | 219 | return null; |
220 | 220 | } |
221 | 221 | |
222 | 222 | $changelog = $this->getRemoteFile($filename, $ref); |
223 | - if ( $changelog === null ) { |
|
223 | + if ($changelog === null) { |
|
224 | 224 | return null; |
225 | 225 | } |
226 | 226 | |
@@ -235,10 +235,10 @@ discard block |
||
235 | 235 | * @return string|null |
236 | 236 | */ |
237 | 237 | protected function findChangelogName($directory = null) { |
238 | - if ( !isset($directory) ) { |
|
238 | + if (!isset($directory)) { |
|
239 | 239 | $directory = $this->localDirectory; |
240 | 240 | } |
241 | - if ( empty($directory) || !is_dir($directory) || ($directory === '.') ) { |
|
241 | + if (empty($directory) || !is_dir($directory) || ($directory === '.')) { |
|
242 | 242 | return null; |
243 | 243 | } |
244 | 244 | |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | $files = scandir($directory); |
247 | 247 | $foundNames = array_intersect($possibleNames, $files); |
248 | 248 | |
249 | - if ( !empty($foundNames) ) { |
|
249 | + if (!empty($foundNames)) { |
|
250 | 250 | return reset($foundNames); |
251 | 251 | } |
252 | 252 | return null; |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | * @param string $directory |
285 | 285 | */ |
286 | 286 | public function setLocalDirectory($directory) { |
287 | - if ( empty($directory) || !is_dir($directory) || ($directory === '.') ) { |
|
287 | + if (empty($directory) || !is_dir($directory) || ($directory === '.')) { |
|
288 | 288 | $this->localDirectory = null; |
289 | 289 | } else { |
290 | 290 | $this->localDirectory = $directory; |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( !class_exists('Puc_v4p4_Vcs_BitBucketApi', false) ): |
|
2 | +if (!class_exists('Puc_v4p4_Vcs_BitBucketApi', false)): |
|
3 | 3 | |
4 | 4 | class Puc_v4p4_Vcs_BitBucketApi extends Puc_v4p4_Vcs_Api { |
5 | 5 | /** |
@@ -19,11 +19,11 @@ discard block |
||
19 | 19 | |
20 | 20 | public function __construct($repositoryUrl, $credentials = array()) { |
21 | 21 | $path = @parse_url($repositoryUrl, PHP_URL_PATH); |
22 | - if ( preg_match('@^/?(?P<username>[^/]+?)/(?P<repository>[^/#?&]+?)/?$@', $path, $matches) ) { |
|
22 | + if (preg_match('@^/?(?P<username>[^/]+?)/(?P<repository>[^/#?&]+?)/?$@', $path, $matches)) { |
|
23 | 23 | $this->username = $matches['username']; |
24 | 24 | $this->repository = $matches['repository']; |
25 | 25 | } else { |
26 | - throw new InvalidArgumentException('Invalid BitBucket repository URL: "' . $repositoryUrl . '"'); |
|
26 | + throw new InvalidArgumentException('Invalid BitBucket repository URL: "'.$repositoryUrl.'"'); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | parent::__construct($repositoryUrl, $credentials); |
@@ -42,11 +42,11 @@ discard block |
||
42 | 42 | $updateSource = $this->getStableTag($configBranch); |
43 | 43 | |
44 | 44 | //Look for version-like tags. |
45 | - if ( !$updateSource && ($configBranch === 'master') ) { |
|
45 | + if (!$updateSource && ($configBranch === 'master')) { |
|
46 | 46 | $updateSource = $this->getLatestTag(); |
47 | 47 | } |
48 | 48 | //If all else fails, use the specified branch itself. |
49 | - if ( !$updateSource ) { |
|
49 | + if (!$updateSource) { |
|
50 | 50 | $updateSource = $this->getBranch($configBranch); |
51 | 51 | } |
52 | 52 | |
@@ -54,8 +54,8 @@ discard block |
||
54 | 54 | } |
55 | 55 | |
56 | 56 | public function getBranch($branchName) { |
57 | - $branch = $this->api('/refs/branches/' . $branchName); |
|
58 | - if ( is_wp_error($branch) || empty($branch) ) { |
|
57 | + $branch = $this->api('/refs/branches/'.$branchName); |
|
58 | + if (is_wp_error($branch) || empty($branch)) { |
|
59 | 59 | return null; |
60 | 60 | } |
61 | 61 | |
@@ -73,8 +73,8 @@ discard block |
||
73 | 73 | * @return Puc_v4p4_Vcs_Reference|null |
74 | 74 | */ |
75 | 75 | public function getTag($tagName) { |
76 | - $tag = $this->api('/refs/tags/' . $tagName); |
|
77 | - if ( is_wp_error($tag) || empty($tag) ) { |
|
76 | + $tag = $this->api('/refs/tags/'.$tagName); |
|
77 | + if (is_wp_error($tag) || empty($tag)) { |
|
78 | 78 | return null; |
79 | 79 | } |
80 | 80 | |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | */ |
94 | 94 | public function getLatestTag() { |
95 | 95 | $tags = $this->api('/refs/tags?sort=-target.date'); |
96 | - if ( !isset($tags, $tags->values) || !is_array($tags->values) ) { |
|
96 | + if (!isset($tags, $tags->values) || !is_array($tags->values)) { |
|
97 | 97 | return null; |
98 | 98 | } |
99 | 99 | |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | $versionTags = $this->sortTagsByVersion($tags->values); |
102 | 102 | |
103 | 103 | //Return the first result. |
104 | - if ( !empty($versionTags) ) { |
|
104 | + if (!empty($versionTags)) { |
|
105 | 105 | $tag = $versionTags[0]; |
106 | 106 | return new Puc_v4p4_Vcs_Reference(array( |
107 | 107 | 'name' => $tag->name, |
@@ -121,12 +121,12 @@ discard block |
||
121 | 121 | */ |
122 | 122 | protected function getStableTag($branch) { |
123 | 123 | $remoteReadme = $this->getRemoteReadme($branch); |
124 | - if ( !empty($remoteReadme['stable_tag']) ) { |
|
124 | + if (!empty($remoteReadme['stable_tag'])) { |
|
125 | 125 | $tag = $remoteReadme['stable_tag']; |
126 | 126 | |
127 | 127 | //You can explicitly opt out of using tags by setting "Stable tag" to |
128 | 128 | //"trunk" or the name of the current branch. |
129 | - if ( ($tag === $branch) || ($tag === 'trunk') ) { |
|
129 | + if (($tag === $branch) || ($tag === 'trunk')) { |
|
130 | 130 | return $this->getBranch($branch); |
131 | 131 | } |
132 | 132 | |
@@ -157,8 +157,8 @@ discard block |
||
157 | 157 | * @return null|string Either the contents of the file, or null if the file doesn't exist or there's an error. |
158 | 158 | */ |
159 | 159 | public function getRemoteFile($path, $ref = 'master') { |
160 | - $response = $this->api('src/' . $ref . '/' . ltrim($path), '1.0'); |
|
161 | - if ( is_wp_error($response) || !isset($response, $response->data) ) { |
|
160 | + $response = $this->api('src/'.$ref.'/'.ltrim($path), '1.0'); |
|
161 | + if (is_wp_error($response) || !isset($response, $response->data)) { |
|
162 | 162 | return null; |
163 | 163 | } |
164 | 164 | return $response->data; |
@@ -171,8 +171,8 @@ discard block |
||
171 | 171 | * @return string|null |
172 | 172 | */ |
173 | 173 | public function getLatestCommitTime($ref) { |
174 | - $response = $this->api('commits/' . $ref); |
|
175 | - if ( isset($response->values, $response->values[0], $response->values[0]->date) ) { |
|
174 | + $response = $this->api('commits/'.$ref); |
|
175 | + if (isset($response->values, $response->values[0], $response->values[0]->date)) { |
|
176 | 176 | return $response->values[0]->date; |
177 | 177 | } |
178 | 178 | return null; |
@@ -196,23 +196,23 @@ discard block |
||
196 | 196 | )); |
197 | 197 | $baseUrl = $url; |
198 | 198 | |
199 | - if ( $this->oauth ) { |
|
200 | - $url = $this->oauth->sign($url,'GET'); |
|
199 | + if ($this->oauth) { |
|
200 | + $url = $this->oauth->sign($url, 'GET'); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | $options = array('timeout' => 10); |
204 | - if ( !empty($this->httpFilterName) ) { |
|
204 | + if (!empty($this->httpFilterName)) { |
|
205 | 205 | $options = apply_filters($this->httpFilterName, $options); |
206 | 206 | } |
207 | 207 | $response = wp_remote_get($url, $options); |
208 | - if ( is_wp_error($response) ) { |
|
208 | + if (is_wp_error($response)) { |
|
209 | 209 | do_action('puc_api_error', $response, null, $url, $this->slug); |
210 | 210 | return $response; |
211 | 211 | } |
212 | 212 | |
213 | 213 | $code = wp_remote_retrieve_response_code($response); |
214 | 214 | $body = wp_remote_retrieve_body($response); |
215 | - if ( $code === 200 ) { |
|
215 | + if ($code === 200) { |
|
216 | 216 | $document = json_decode($body); |
217 | 217 | return $document; |
218 | 218 | } |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | public function setAuthentication($credentials) { |
233 | 233 | parent::setAuthentication($credentials); |
234 | 234 | |
235 | - if ( !empty($credentials) && !empty($credentials['consumer_key']) ) { |
|
235 | + if (!empty($credentials) && !empty($credentials['consumer_key'])) { |
|
236 | 236 | $this->oauth = new Puc_v4p4_OAuthSignature( |
237 | 237 | $credentials['consumer_key'], |
238 | 238 | $credentials['consumer_secret'] |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | //Add authentication data to download URLs. Since OAuth signatures incorporate |
247 | 247 | //timestamps, we have to do this immediately before inserting the update. Otherwise |
248 | 248 | //authentication could fail due to a stale timestamp. |
249 | - if ( $this->oauth ) { |
|
249 | + if ($this->oauth) { |
|
250 | 250 | $url = $this->oauth->sign($url); |
251 | 251 | } |
252 | 252 | return $url; |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if ( !class_exists('Puc_v4p4_Vcs_GitHubApi', false) ): |
|
3 | +if (!class_exists('Puc_v4p4_Vcs_GitHubApi', false)): |
|
4 | 4 | |
5 | 5 | class Puc_v4p4_Vcs_GitHubApi extends Puc_v4p4_Vcs_Api { |
6 | 6 | /** |
@@ -39,11 +39,11 @@ discard block |
||
39 | 39 | |
40 | 40 | public function __construct($repositoryUrl, $accessToken = null) { |
41 | 41 | $path = @parse_url($repositoryUrl, PHP_URL_PATH); |
42 | - if ( preg_match('@^/?(?P<username>[^/]+?)/(?P<repository>[^/#?&]+?)/?$@', $path, $matches) ) { |
|
42 | + if (preg_match('@^/?(?P<username>[^/]+?)/(?P<repository>[^/#?&]+?)/?$@', $path, $matches)) { |
|
43 | 43 | $this->userName = $matches['username']; |
44 | 44 | $this->repositoryName = $matches['repository']; |
45 | 45 | } else { |
46 | - throw new InvalidArgumentException('Invalid GitHub repository URL: "' . $repositoryUrl . '"'); |
|
46 | + throw new InvalidArgumentException('Invalid GitHub repository URL: "'.$repositoryUrl.'"'); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | parent::__construct($repositoryUrl, $accessToken); |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | */ |
57 | 57 | public function getLatestRelease() { |
58 | 58 | $release = $this->api('/repos/:user/:repo/releases/latest'); |
59 | - if ( is_wp_error($release) || !is_object($release) || !isset($release->tag_name) ) { |
|
59 | + if (is_wp_error($release) || !is_object($release) || !isset($release->tag_name)) { |
|
60 | 60 | return null; |
61 | 61 | } |
62 | 62 | |
@@ -68,15 +68,15 @@ discard block |
||
68 | 68 | 'apiResponse' => $release, |
69 | 69 | )); |
70 | 70 | |
71 | - if ( isset($release->assets[0]) ) { |
|
71 | + if (isset($release->assets[0])) { |
|
72 | 72 | $reference->downloadCount = $release->assets[0]->download_count; |
73 | 73 | } |
74 | 74 | |
75 | - if ( $this->releaseAssetsEnabled && isset($release->assets, $release->assets[0]) ) { |
|
75 | + if ($this->releaseAssetsEnabled && isset($release->assets, $release->assets[0])) { |
|
76 | 76 | //Use the first release asset that matches the specified regular expression. |
77 | 77 | $matchingAssets = array_filter($release->assets, array($this, 'matchesAssetFilter')); |
78 | - if ( !empty($matchingAssets) ) { |
|
79 | - if ( $this->isAuthenticationEnabled() ) { |
|
78 | + if (!empty($matchingAssets)) { |
|
79 | + if ($this->isAuthenticationEnabled()) { |
|
80 | 80 | /** |
81 | 81 | * Keep in mind that we'll need to add an "Accept" header to download this asset. |
82 | 82 | * @see setReleaseDownloadHeader() |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | } |
93 | 93 | } |
94 | 94 | |
95 | - if ( !empty($release->body) ) { |
|
95 | + if (!empty($release->body)) { |
|
96 | 96 | /** @noinspection PhpUndefinedClassInspection */ |
97 | 97 | $reference->changelog = Parsedown::instance()->text($release->body); |
98 | 98 | } |
@@ -108,12 +108,12 @@ discard block |
||
108 | 108 | public function getLatestTag() { |
109 | 109 | $tags = $this->api('/repos/:user/:repo/tags'); |
110 | 110 | |
111 | - if ( is_wp_error($tags) || empty($tags) || !is_array($tags) ) { |
|
111 | + if (is_wp_error($tags) || empty($tags) || !is_array($tags)) { |
|
112 | 112 | return null; |
113 | 113 | } |
114 | 114 | |
115 | 115 | $versionTags = $this->sortTagsByVersion($tags); |
116 | - if ( empty($versionTags) ) { |
|
116 | + if (empty($versionTags)) { |
|
117 | 117 | return null; |
118 | 118 | } |
119 | 119 | |
@@ -133,8 +133,8 @@ discard block |
||
133 | 133 | * @return null|Puc_v4p4_Vcs_Reference |
134 | 134 | */ |
135 | 135 | public function getBranch($branchName) { |
136 | - $branch = $this->api('/repos/:user/:repo/branches/' . $branchName); |
|
137 | - if ( is_wp_error($branch) || empty($branch) ) { |
|
136 | + $branch = $this->api('/repos/:user/:repo/branches/'.$branchName); |
|
137 | + if (is_wp_error($branch) || empty($branch)) { |
|
138 | 138 | return null; |
139 | 139 | } |
140 | 140 | |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | 'apiResponse' => $branch, |
145 | 145 | )); |
146 | 146 | |
147 | - if ( isset($branch->commit, $branch->commit->commit, $branch->commit->commit->author->date) ) { |
|
147 | + if (isset($branch->commit, $branch->commit->commit, $branch->commit->commit->author->date)) { |
|
148 | 148 | $reference->updated = $branch->commit->commit->author->date; |
149 | 149 | } |
150 | 150 | |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | 'sha' => $ref, |
167 | 167 | ) |
168 | 168 | ); |
169 | - if ( !is_wp_error($commits) && is_array($commits) && isset($commits[0]) ) { |
|
169 | + if (!is_wp_error($commits) && is_array($commits) && isset($commits[0])) { |
|
170 | 170 | return $commits[0]; |
171 | 171 | } |
172 | 172 | return null; |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | */ |
181 | 181 | public function getLatestCommitTime($ref) { |
182 | 182 | $commits = $this->api('/repos/:user/:repo/commits', array('sha' => $ref)); |
183 | - if ( !is_wp_error($commits) && is_array($commits) && isset($commits[0]) ) { |
|
183 | + if (!is_wp_error($commits) && is_array($commits) && isset($commits[0])) { |
|
184 | 184 | return $commits[0]->commit->author->date; |
185 | 185 | } |
186 | 186 | return null; |
@@ -198,18 +198,18 @@ discard block |
||
198 | 198 | $url = $this->buildApiUrl($url, $queryParams); |
199 | 199 | |
200 | 200 | $options = array('timeout' => 10); |
201 | - if ( !empty($this->httpFilterName) ) { |
|
201 | + if (!empty($this->httpFilterName)) { |
|
202 | 202 | $options = apply_filters($this->httpFilterName, $options); |
203 | 203 | } |
204 | 204 | $response = wp_remote_get($url, $options); |
205 | - if ( is_wp_error($response) ) { |
|
205 | + if (is_wp_error($response)) { |
|
206 | 206 | do_action('puc_api_error', $response, null, $url, $this->slug); |
207 | 207 | return $response; |
208 | 208 | } |
209 | 209 | |
210 | 210 | $code = wp_remote_retrieve_response_code($response); |
211 | 211 | $body = wp_remote_retrieve_body($response); |
212 | - if ( $code === 200 ) { |
|
212 | + if ($code === 200) { |
|
213 | 213 | $document = json_decode($body); |
214 | 214 | return $document; |
215 | 215 | } |
@@ -236,14 +236,14 @@ discard block |
||
236 | 236 | 'repo' => $this->repositoryName, |
237 | 237 | ); |
238 | 238 | foreach ($variables as $name => $value) { |
239 | - $url = str_replace('/:' . $name, '/' . urlencode($value), $url); |
|
239 | + $url = str_replace('/:'.$name, '/'.urlencode($value), $url); |
|
240 | 240 | } |
241 | - $url = 'https://api.github.com' . $url; |
|
241 | + $url = 'https://api.github.com'.$url; |
|
242 | 242 | |
243 | - if ( !empty($this->accessToken) ) { |
|
243 | + if (!empty($this->accessToken)) { |
|
244 | 244 | $queryParams['access_token'] = $this->accessToken; |
245 | 245 | } |
246 | - if ( !empty($queryParams) ) { |
|
246 | + if (!empty($queryParams)) { |
|
247 | 247 | $url = add_query_arg($queryParams, $url); |
248 | 248 | } |
249 | 249 | |
@@ -258,10 +258,10 @@ discard block |
||
258 | 258 | * @return null|string Either the contents of the file, or null if the file doesn't exist or there's an error. |
259 | 259 | */ |
260 | 260 | public function getRemoteFile($path, $ref = 'master') { |
261 | - $apiUrl = '/repos/:user/:repo/contents/' . $path; |
|
261 | + $apiUrl = '/repos/:user/:repo/contents/'.$path; |
|
262 | 262 | $response = $this->api($apiUrl, array('ref' => $ref)); |
263 | 263 | |
264 | - if ( is_wp_error($response) || !isset($response->content) || ($response->encoding !== 'base64') ) { |
|
264 | + if (is_wp_error($response) || !isset($response->content) || ($response->encoding !== 'base64')) { |
|
265 | 265 | return null; |
266 | 266 | } |
267 | 267 | return base64_decode($response->content); |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | urlencode($this->repositoryName), |
281 | 281 | urlencode($ref) |
282 | 282 | ); |
283 | - if ( !empty($this->accessToken) ) { |
|
283 | + if (!empty($this->accessToken)) { |
|
284 | 284 | $url = $this->signDownloadUrl($url); |
285 | 285 | } |
286 | 286 | return $url; |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | */ |
295 | 295 | public function getTag($tagName) { |
296 | 296 | //The current GitHub update checker doesn't use getTag, so I didn't bother to implement it. |
297 | - throw new LogicException('The ' . __METHOD__ . ' method is not implemented and should not be used.'); |
|
297 | + throw new LogicException('The '.__METHOD__.' method is not implemented and should not be used.'); |
|
298 | 298 | } |
299 | 299 | |
300 | 300 | public function setAuthentication($credentials) { |
@@ -311,16 +311,16 @@ discard block |
||
311 | 311 | public function chooseReference($configBranch) { |
312 | 312 | $updateSource = null; |
313 | 313 | |
314 | - if ( $configBranch === 'master' ) { |
|
314 | + if ($configBranch === 'master') { |
|
315 | 315 | //Use the latest release. |
316 | 316 | $updateSource = $this->getLatestRelease(); |
317 | - if ( $updateSource === null ) { |
|
317 | + if ($updateSource === null) { |
|
318 | 318 | //Failing that, use the tag with the highest version number. |
319 | 319 | $updateSource = $this->getLatestTag(); |
320 | 320 | } |
321 | 321 | } |
322 | 322 | //Alternatively, just use the branch itself. |
323 | - if ( empty($updateSource) ) { |
|
323 | + if (empty($updateSource)) { |
|
324 | 324 | $updateSource = $this->getBranch($configBranch); |
325 | 325 | } |
326 | 326 | |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | * @return string |
333 | 333 | */ |
334 | 334 | public function signDownloadUrl($url) { |
335 | - if ( empty($this->credentials) ) { |
|
335 | + if (empty($this->credentials)) { |
|
336 | 336 | return $url; |
337 | 337 | } |
338 | 338 | return add_query_arg('access_token', $this->credentials, $url); |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | * @return bool |
370 | 370 | */ |
371 | 371 | protected function matchesAssetFilter($releaseAsset) { |
372 | - if ( $this->assetFilterRegex === null ) { |
|
372 | + if ($this->assetFilterRegex === null) { |
|
373 | 373 | //The default is to accept all assets. |
374 | 374 | return true; |
375 | 375 | } |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | */ |
384 | 384 | public function addHttpRequestFilter($result) { |
385 | 385 | static $filterAdded = false; |
386 | - if ( $this->releaseAssetsEnabled && !$filterAdded && $this->isAuthenticationEnabled() ) { |
|
386 | + if ($this->releaseAssetsEnabled && !$filterAdded && $this->isAuthenticationEnabled()) { |
|
387 | 387 | add_filter('http_request_args', array($this, 'setReleaseDownloadHeader'), 10, 2); |
388 | 388 | $filterAdded = true; |
389 | 389 | } |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | */ |
404 | 404 | public function setReleaseDownloadHeader($requestArgs, $url = '') { |
405 | 405 | //Is WordPress trying to download one of our assets? |
406 | - if ( strpos($url, $this->assetApiBaseUrl) !== false ) { |
|
406 | + if (strpos($url, $this->assetApiBaseUrl) !== false) { |
|
407 | 407 | $requestArgs['headers']['accept'] = 'application/octet-stream'; |
408 | 408 | } |
409 | 409 | return $requestArgs; |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( !class_exists('Puc_v4p4_Vcs_PluginUpdateChecker') ): |
|
2 | +if (!class_exists('Puc_v4p4_Vcs_PluginUpdateChecker')): |
|
3 | 3 | |
4 | 4 | class Puc_v4p4_Vcs_PluginUpdateChecker extends Puc_v4p4_Plugin_UpdateChecker implements Puc_v4p4_Vcs_BaseChecker { |
5 | 5 | /** |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | public function requestInfo($unusedParameter = null) { |
35 | 35 | //We have to make several remote API requests to gather all the necessary info |
36 | 36 | //which can take a while on slow networks. |
37 | - if ( function_exists('set_time_limit') ) { |
|
37 | + if (function_exists('set_time_limit')) { |
|
38 | 38 | @set_time_limit(60); |
39 | 39 | } |
40 | 40 | |
@@ -49,16 +49,16 @@ discard block |
||
49 | 49 | |
50 | 50 | //Pick a branch or tag. |
51 | 51 | $updateSource = $api->chooseReference($this->branch); |
52 | - if ( $updateSource ) { |
|
52 | + if ($updateSource) { |
|
53 | 53 | $ref = $updateSource->name; |
54 | 54 | $info->version = $updateSource->version; |
55 | 55 | $info->last_updated = $updateSource->updated; |
56 | 56 | $info->download_url = $updateSource->downloadUrl; |
57 | 57 | |
58 | - if ( !empty($updateSource->changelog) ) { |
|
58 | + if (!empty($updateSource->changelog)) { |
|
59 | 59 | $info->sections['changelog'] = $updateSource->changelog; |
60 | 60 | } |
61 | - if ( isset($updateSource->downloadCount) ) { |
|
61 | + if (isset($updateSource->downloadCount)) { |
|
62 | 62 | $info->downloaded = $updateSource->downloadCount; |
63 | 63 | } |
64 | 64 | } else { |
@@ -80,29 +80,29 @@ discard block |
||
80 | 80 | //are what the WordPress install will actually see after upgrading, so they take precedence over releases/tags. |
81 | 81 | $mainPluginFile = basename($this->pluginFile); |
82 | 82 | $remotePlugin = $api->getRemoteFile($mainPluginFile, $ref); |
83 | - if ( !empty($remotePlugin) ) { |
|
83 | + if (!empty($remotePlugin)) { |
|
84 | 84 | $remoteHeader = $this->getFileHeader($remotePlugin); |
85 | 85 | $this->setInfoFromHeader($remoteHeader, $info); |
86 | 86 | } |
87 | 87 | |
88 | 88 | //Try parsing readme.txt. If it's formatted according to WordPress.org standards, it will contain |
89 | 89 | //a lot of useful information like the required/tested WP version, changelog, and so on. |
90 | - if ( $this->readmeTxtExistsLocally() ) { |
|
90 | + if ($this->readmeTxtExistsLocally()) { |
|
91 | 91 | $this->setInfoFromRemoteReadme($ref, $info); |
92 | 92 | } |
93 | 93 | |
94 | 94 | //The changelog might be in a separate file. |
95 | - if ( empty($info->sections['changelog']) ) { |
|
95 | + if (empty($info->sections['changelog'])) { |
|
96 | 96 | $info->sections['changelog'] = $api->getRemoteChangelog($ref, dirname($this->getAbsolutePath())); |
97 | - if ( empty($info->sections['changelog']) ) { |
|
97 | + if (empty($info->sections['changelog'])) { |
|
98 | 98 | $info->sections['changelog'] = __('There is no changelog available.', 'plugin-update-checker'); |
99 | 99 | } |
100 | 100 | } |
101 | 101 | |
102 | - if ( empty($info->last_updated) ) { |
|
102 | + if (empty($info->last_updated)) { |
|
103 | 103 | //Fetch the latest commit that changed the tag or branch and use it as the "last_updated" date. |
104 | 104 | $latestCommitTime = $api->getLatestCommitTime($ref); |
105 | - if ( $latestCommitTime !== null ) { |
|
105 | + if ($latestCommitTime !== null) { |
|
106 | 106 | $info->last_updated = $latestCommitTime; |
107 | 107 | } |
108 | 108 | } |
@@ -118,10 +118,10 @@ discard block |
||
118 | 118 | */ |
119 | 119 | protected function readmeTxtExistsLocally() { |
120 | 120 | $pluginDirectory = $this->getAbsoluteDirectoryPath(); |
121 | - if ( empty($pluginDirectory) || !is_dir($pluginDirectory) || ($pluginDirectory === '.') ) { |
|
121 | + if (empty($pluginDirectory) || !is_dir($pluginDirectory) || ($pluginDirectory === '.')) { |
|
122 | 122 | return false; |
123 | 123 | } |
124 | - return is_file($pluginDirectory . '/' . $this->api->getLocalReadmeName()); |
|
124 | + return is_file($pluginDirectory.'/'.$this->api->getLocalReadmeName()); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -145,12 +145,12 @@ discard block |
||
145 | 145 | 'Tested up to' => 'tested', |
146 | 146 | ); |
147 | 147 | foreach ($headerToPropertyMap as $headerName => $property) { |
148 | - if ( isset($fileHeader[$headerName]) && !empty($fileHeader[$headerName]) ) { |
|
148 | + if (isset($fileHeader[$headerName]) && !empty($fileHeader[$headerName])) { |
|
149 | 149 | $pluginInfo->$property = $fileHeader[$headerName]; |
150 | 150 | } |
151 | 151 | } |
152 | 152 | |
153 | - if ( !empty($fileHeader['Description']) ) { |
|
153 | + if (!empty($fileHeader['Description'])) { |
|
154 | 154 | $pluginInfo->sections['description'] = $fileHeader['Description']; |
155 | 155 | } |
156 | 156 | } |
@@ -163,21 +163,21 @@ discard block |
||
163 | 163 | */ |
164 | 164 | protected function setInfoFromRemoteReadme($ref, $pluginInfo) { |
165 | 165 | $readme = $this->api->getRemoteReadme($ref); |
166 | - if ( empty($readme) ) { |
|
166 | + if (empty($readme)) { |
|
167 | 167 | return; |
168 | 168 | } |
169 | 169 | |
170 | - if ( isset($readme['sections']) ) { |
|
170 | + if (isset($readme['sections'])) { |
|
171 | 171 | $pluginInfo->sections = array_merge($pluginInfo->sections, $readme['sections']); |
172 | 172 | } |
173 | - if ( !empty($readme['tested_up_to']) ) { |
|
173 | + if (!empty($readme['tested_up_to'])) { |
|
174 | 174 | $pluginInfo->tested = $readme['tested_up_to']; |
175 | 175 | } |
176 | - if ( !empty($readme['requires_at_least']) ) { |
|
176 | + if (!empty($readme['requires_at_least'])) { |
|
177 | 177 | $pluginInfo->requires = $readme['requires_at_least']; |
178 | 178 | } |
179 | 179 | |
180 | - if ( isset($readme['upgrade_notice'], $readme['upgrade_notice'][$pluginInfo->version]) ) { |
|
180 | + if (isset($readme['upgrade_notice'], $readme['upgrade_notice'][$pluginInfo->version])) { |
|
181 | 181 | $pluginInfo->upgrade_notice = $readme['upgrade_notice'][$pluginInfo->version]; |
182 | 182 | } |
183 | 183 | } |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | public function getUpdate() { |
200 | 200 | $update = parent::getUpdate(); |
201 | 201 | |
202 | - if ( isset($update) && !empty($update->download_url) ) { |
|
202 | + if (isset($update) && !empty($update->download_url)) { |
|
203 | 203 | $update->download_url = $this->api->signDownloadUrl($update->download_url); |
204 | 204 | } |
205 | 205 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if ( !class_exists('Puc_v4p4_StateStore', false) ): |
|
3 | +if (!class_exists('Puc_v4p4_StateStore', false)): |
|
4 | 4 | |
5 | 5 | class Puc_v4p4_StateStore { |
6 | 6 | /** |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | */ |
108 | 108 | public function getTranslations() { |
109 | 109 | $this->lazyLoad(); |
110 | - if ( isset($this->update, $this->update->translations) ) { |
|
110 | + if (isset($this->update, $this->update->translations)) { |
|
111 | 111 | return $this->update->translations; |
112 | 112 | } |
113 | 113 | return array(); |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | */ |
121 | 121 | public function setTranslations($translationUpdates) { |
122 | 122 | $this->lazyLoad(); |
123 | - if ( isset($this->update) ) { |
|
123 | + if (isset($this->update)) { |
|
124 | 124 | $this->update->translations = $translationUpdates; |
125 | 125 | $this->save(); |
126 | 126 | } |
@@ -132,13 +132,13 @@ discard block |
||
132 | 132 | $state->lastCheck = $this->lastCheck; |
133 | 133 | $state->checkedVersion = $this->checkedVersion; |
134 | 134 | |
135 | - if ( isset($this->update)) { |
|
135 | + if (isset($this->update)) { |
|
136 | 136 | $state->update = $this->update->toStdClass(); |
137 | 137 | |
138 | 138 | $updateClass = get_class($this->update); |
139 | 139 | $state->updateClass = $updateClass; |
140 | 140 | $prefix = $this->getLibPrefix(); |
141 | - if ( Puc_v4p4_Utils::startsWith($updateClass, $prefix) ) { |
|
141 | + if (Puc_v4p4_Utils::startsWith($updateClass, $prefix)) { |
|
142 | 142 | $state->updateBaseClass = substr($updateClass, strlen($prefix)); |
143 | 143 | } |
144 | 144 | } |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | * @return $this |
152 | 152 | */ |
153 | 153 | public function lazyLoad() { |
154 | - if ( !$this->isLoaded ) { |
|
154 | + if (!$this->isLoaded) { |
|
155 | 155 | $this->load(); |
156 | 156 | } |
157 | 157 | return $this; |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | |
163 | 163 | $state = get_site_option($this->optionName, null); |
164 | 164 | |
165 | - if ( !is_object($state) ) { |
|
165 | + if (!is_object($state)) { |
|
166 | 166 | $this->lastCheck = 0; |
167 | 167 | $this->checkedVersion = ''; |
168 | 168 | $this->update = null; |
@@ -173,18 +173,18 @@ discard block |
||
173 | 173 | $this->checkedVersion = Puc_v4p4_Utils::get($state, 'checkedVersion', ''); |
174 | 174 | $this->update = null; |
175 | 175 | |
176 | - if ( isset($state->update) ) { |
|
176 | + if (isset($state->update)) { |
|
177 | 177 | //This mess is due to the fact that the want the update class from this version |
178 | 178 | //of the library, not the version that saved the update. |
179 | 179 | |
180 | 180 | $updateClass = null; |
181 | - if ( isset($state->updateBaseClass) ) { |
|
182 | - $updateClass = $this->getLibPrefix() . $state->updateBaseClass; |
|
183 | - } else if ( isset($state->updateClass) && class_exists($state->updateClass) ) { |
|
181 | + if (isset($state->updateBaseClass)) { |
|
182 | + $updateClass = $this->getLibPrefix().$state->updateBaseClass; |
|
183 | + } else if (isset($state->updateClass) && class_exists($state->updateClass)) { |
|
184 | 184 | $updateClass = $state->updateClass; |
185 | 185 | } |
186 | 186 | |
187 | - if ( $updateClass !== null ) { |
|
187 | + if ($updateClass !== null) { |
|
188 | 188 | $this->update = call_user_func(array($updateClass, 'fromObject'), $state->update); |
189 | 189 | } |
190 | 190 | } |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | |
201 | 201 | private function getLibPrefix() { |
202 | 202 | $parts = explode('_', __CLASS__, 3); |
203 | - return $parts[0] . '_' . $parts[1] . '_'; |
|
203 | + return $parts[0].'_'.$parts[1].'_'; |
|
204 | 204 | } |
205 | 205 | } |
206 | 206 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if ( !class_exists('Puc_v4p4_OAuthSignature', false) ): |
|
3 | +if (!class_exists('Puc_v4p4_OAuthSignature', false)): |
|
4 | 4 | |
5 | 5 | /** |
6 | 6 | * A basic signature generator for zero-legged OAuth 1.0. |
@@ -26,9 +26,9 @@ discard block |
||
26 | 26 | |
27 | 27 | //Parse query parameters. |
28 | 28 | $query = @parse_url($url, PHP_URL_QUERY); |
29 | - if ( !empty($query) ) { |
|
29 | + if (!empty($query)) { |
|
30 | 30 | parse_str($query, $parsedParams); |
31 | - if ( is_array($parameters) ) { |
|
31 | + if (is_array($parameters)) { |
|
32 | 32 | $parameters = $parsedParams; |
33 | 33 | } |
34 | 34 | //Remove the query string from the URL. We'll replace it later. |
@@ -58,19 +58,19 @@ discard block |
||
58 | 58 | $encodedUrl = urlencode($url); |
59 | 59 | $encodedParams = urlencode(http_build_query($parameters, '', '&')); |
60 | 60 | |
61 | - $stringToSign = $encodedVerb . '&' . $encodedUrl . '&' . $encodedParams; |
|
61 | + $stringToSign = $encodedVerb.'&'.$encodedUrl.'&'.$encodedParams; |
|
62 | 62 | |
63 | 63 | //Since we only have one OAuth token (the consumer secret) we only have |
64 | 64 | //to use it as our HMAC key. However, we still have to append an & to it |
65 | 65 | //as if we were using it with additional tokens. |
66 | - $secret = urlencode($this->consumerSecret) . '&'; |
|
66 | + $secret = urlencode($this->consumerSecret).'&'; |
|
67 | 67 | |
68 | 68 | //The signature is a hash of the consumer key and the base string. Note |
69 | 69 | //that we have to get the raw output from hash_hmac and base64 encode |
70 | 70 | //the binary data result. |
71 | 71 | $parameters['oauth_signature'] = base64_encode(hash_hmac('sha1', $stringToSign, $secret, true)); |
72 | 72 | |
73 | - return ($url . '?' . http_build_query($parameters)); |
|
73 | + return ($url.'?'.http_build_query($parameters)); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | private function nonce() { |
82 | 82 | $mt = microtime(); |
83 | 83 | $rand = mt_rand(); |
84 | - return md5($mt . '_' . $rand); |
|
84 | + return md5($mt.'_'.$rand); |
|
85 | 85 | } |
86 | 86 | } |
87 | 87 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( !class_exists('Puc_v4p4_Metadata', false) ): |
|
2 | +if (!class_exists('Puc_v4p4_Metadata', false)): |
|
3 | 3 | |
4 | 4 | /** |
5 | 5 | * A base container for holding information about updates and plugin metadata. |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | * @return self |
19 | 19 | */ |
20 | 20 | public static function fromJson(/** @noinspection PhpUnusedParameterInspection */ $json) { |
21 | - throw new LogicException('The ' . __METHOD__ . ' method must be implemented by subclasses'); |
|
21 | + throw new LogicException('The '.__METHOD__.' method must be implemented by subclasses'); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | /** |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | protected static function createFromJson($json, $target) { |
30 | 30 | /** @var StdClass $apiResponse */ |
31 | 31 | $apiResponse = json_decode($json); |
32 | - if ( empty($apiResponse) || !is_object($apiResponse) ){ |
|
32 | + if (empty($apiResponse) || !is_object($apiResponse)) { |
|
33 | 33 | $errorMessage = "Failed to parse update metadata. Try validating your .json file with http://jsonlint.com/"; |
34 | 34 | do_action('puc_api_error', new WP_Error('puc-invalid-json', $errorMessage)); |
35 | 35 | trigger_error($errorMessage, E_USER_NOTICE); |
@@ -37,13 +37,13 @@ discard block |
||
37 | 37 | } |
38 | 38 | |
39 | 39 | $valid = $target->validateMetadata($apiResponse); |
40 | - if ( is_wp_error($valid) ){ |
|
40 | + if (is_wp_error($valid)) { |
|
41 | 41 | do_action('puc_api_error', $valid); |
42 | 42 | trigger_error($valid->get_error_message(), E_USER_NOTICE); |
43 | 43 | return false; |
44 | 44 | } |
45 | 45 | |
46 | - foreach(get_object_vars($apiResponse) as $key => $value){ |
|
46 | + foreach (get_object_vars($apiResponse) as $key => $value) { |
|
47 | 47 | $target->$key = $value; |
48 | 48 | } |
49 | 49 | |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | * @return self The new copy. |
69 | 69 | */ |
70 | 70 | public static function fromObject(/** @noinspection PhpUnusedParameterInspection */ $object) { |
71 | - throw new LogicException('The ' . __METHOD__ . ' method must be implemented by subclasses'); |
|
71 | + throw new LogicException('The '.__METHOD__.' method must be implemented by subclasses'); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -101,13 +101,13 @@ discard block |
||
101 | 101 | protected function copyFields($from, $to) { |
102 | 102 | $fields = $this->getFieldNames(); |
103 | 103 | |
104 | - if ( property_exists($from, 'slug') && !empty($from->slug) ) { |
|
104 | + if (property_exists($from, 'slug') && !empty($from->slug)) { |
|
105 | 105 | //Let plugins add extra fields without having to create subclasses. |
106 | - $fields = apply_filters($this->getPrefixedFilter('retain_fields') . '-' . $from->slug, $fields); |
|
106 | + $fields = apply_filters($this->getPrefixedFilter('retain_fields').'-'.$from->slug, $fields); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | foreach ($fields as $field) { |
110 | - if ( property_exists($from, $field) ) { |
|
110 | + if (property_exists($from, $field)) { |
|
111 | 111 | $to->$field = $from->$field; |
112 | 112 | } |
113 | 113 | } |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | * @return string |
126 | 126 | */ |
127 | 127 | protected function getPrefixedFilter($tag) { |
128 | - return 'puc_' . $tag; |
|
128 | + return 'puc_'.$tag; |
|
129 | 129 | } |
130 | 130 | } |
131 | 131 |