Passed
Push — main ( 08833b...a8114c )
by smiley
01:44
created
src/MagicAPI/EndpointMapInterface.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,6 +15,6 @@
 block discarded – undo
15 15
 /**
16 16
  * @property string $API_BASE
17 17
  */
18
-interface EndpointMapInterface extends SettingsContainerInterface{
18
+interface EndpointMapInterface extends SettingsContainerInterface {
19 19
 
20 20
 }
Please login to merge, or discard this patch.
src/Core/OAuthProvider.php 2 patches
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
  * @property string                                          $serviceName
40 40
  * @property string|null                                     $userRevokeURL
41 41
  */
42
-abstract class OAuthProvider implements OAuthInterface{
42
+abstract class OAuthProvider implements OAuthInterface {
43 43
 	use LoggerAwareTrait;
44 44
 
45 45
 	protected const ALLOWED_PROPERTIES = [
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 		OAuthStorageInterface $storage,
154 154
 		SettingsContainerInterface $options,
155 155
 		LoggerInterface $logger = null
156
-	){
156
+	) {
157 157
 		$this->http    = $http;
158 158
 		$this->storage = $storage;
159 159
 		$this->options = $options;
@@ -165,10 +165,10 @@  discard block
 block discarded – undo
165 165
 
166 166
 		$this->serviceName = (new ReflectionClass($this))->getShortName();
167 167
 
168
-		if(!empty($this->endpointMap) && class_exists($this->endpointMap)){
168
+		if (!empty($this->endpointMap) && class_exists($this->endpointMap)) {
169 169
 			$this->endpoints = new $this->endpointMap;
170 170
 
171
-			if(!$this->endpoints instanceof EndpointMapInterface){
171
+			if (!$this->endpoints instanceof EndpointMapInterface) {
172 172
 				throw new ApiClientException('invalid endpoint map'); // @codeCoverageIgnore
173 173
 			}
174 174
 
@@ -181,9 +181,9 @@  discard block
 block discarded – undo
181 181
 	 *
182 182
 	 * @return mixed|null
183 183
 	 */
184
-	public function __get(string $name){
184
+	public function __get(string $name) {
185 185
 
186
-		if(in_array($name, $this::ALLOWED_PROPERTIES, true)){
186
+		if (in_array($name, $this::ALLOWED_PROPERTIES, true)) {
187 187
 			return $this->{$name};
188 188
 		}
189 189
 
@@ -244,11 +244,11 @@  discard block
 block discarded – undo
244 244
 	 */
245 245
 	public function __call(string $endpointName, array $arguments):ResponseInterface{
246 246
 
247
-		if(!$this->endpoints instanceof EndpointMap){
247
+		if (!$this->endpoints instanceof EndpointMap) {
248 248
 			throw new ApiClientException('MagicAPI not available');
249 249
 		}
250 250
 
251
-		if(!isset($this->endpoints->{$endpointName})){
251
+		if (!isset($this->endpoints->{$endpointName})) {
252 252
 			throw new ApiClientException('endpoint not found: "'.$endpointName.'"');
253 253
 		}
254 254
 
@@ -261,21 +261,21 @@  discard block
 block discarded – undo
261 261
 		$path_elements = $m['path_elements'] ?? [];
262 262
 		$params_in_url = count($path_elements);
263 263
 		$params        = $arguments[$params_in_url] ?? [];
264
-		$urlparams     = array_slice($arguments,0 , $params_in_url);
264
+		$urlparams     = array_slice($arguments, 0, $params_in_url);
265 265
 
266
-		if($params_in_url > 0){
266
+		if ($params_in_url > 0) {
267 267
 
268
-			if(count($urlparams) < $params_in_url){
268
+			if (count($urlparams) < $params_in_url) {
269 269
 				throw new APIClientException('too few URL params, required: '.implode(', ', $path_elements));
270 270
 			}
271 271
 
272 272
 			$endpoint = sprintf($endpoint, ...$urlparams);
273 273
 		}
274 274
 
275
-		if(in_array($method, ['POST', 'PATCH', 'PUT', 'DELETE'])){
275
+		if (in_array($method, ['POST', 'PATCH', 'PUT', 'DELETE'])) {
276 276
 			$body = $arguments[$params_in_url + 1] ?? $params;
277 277
 
278
-			if($params === $body){
278
+			if ($params === $body) {
279 279
 				$params = [];
280 280
 			}
281 281
 
@@ -325,28 +325,28 @@  discard block
 block discarded – undo
325 325
 		$request = $this->requestFactory
326 326
 			->createRequest($method ?? 'GET', merge_query($this->apiURL.$path, $params ?? []));
327 327
 
328
-		foreach(array_merge($this->apiHeaders, $headers ?? []) as $header => $value){
328
+		foreach (array_merge($this->apiHeaders, $headers ?? []) as $header => $value) {
329 329
 			$request = $request->withAddedHeader($header, $value);
330 330
 		}
331 331
 
332
-		if($request->hasHeader('content-type')){
332
+		if ($request->hasHeader('content-type')) {
333 333
 			$contentType = strtolower($request->getHeaderLine('content-type'));
334 334
 
335
-			if(is_array($body)){
336
-				if($contentType === 'application/x-www-form-urlencoded'){
335
+			if (is_array($body)) {
336
+				if ($contentType === 'application/x-www-form-urlencoded') {
337 337
 					$body = $this->streamFactory->createStream(http_build_query($body, '', '&', PHP_QUERY_RFC1738));
338 338
 				}
339
-				elseif($contentType === 'application/json' || $contentType === 'application/vnd.api+json'){
339
+				elseif ($contentType === 'application/json' || $contentType === 'application/vnd.api+json') {
340 340
 					$body = $this->streamFactory->createStream(json_encode($body));
341 341
 				}
342 342
 			}
343
-			elseif(is_string($body)){
343
+			elseif (is_string($body)) {
344 344
 				// we don't check if the given string matches the content type - this is the implementor's responsibility
345 345
 				$body = $this->streamFactory->createStream($body);
346 346
 			}
347 347
 		}
348 348
 
349
-		if($body instanceof StreamInterface){
349
+		if ($body instanceof StreamInterface) {
350 350
 			$request = $request
351 351
 				->withBody($body)
352 352
 				->withHeader('Content-length', (string)$body->getSize())
@@ -362,15 +362,15 @@  discard block
 block discarded – undo
362 362
 	public function sendRequest(RequestInterface $request):ResponseInterface{
363 363
 
364 364
 		// get authorization only if we request the provider API
365
-		if(strpos((string)$request->getUri(), $this->apiURL) === 0){
365
+		if (strpos((string)$request->getUri(), $this->apiURL) === 0) {
366 366
 			$token = $this->storage->getAccessToken($this->serviceName);
367 367
 
368 368
 			// attempt to refresh an expired token
369
-			if(
369
+			if (
370 370
 				$this instanceof TokenRefresh
371 371
 				&& $this->options->tokenAutoRefresh
372 372
 				&& ($token->isExpired() || $token->expires === $token::EOL_UNKNOWN)
373
-			){
373
+			) {
374 374
 				$token = $this->refreshAccessToken($token);
375 375
 			}
376 376
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -335,12 +335,10 @@
 block discarded – undo
335 335
 			if(is_array($body)){
336 336
 				if($contentType === 'application/x-www-form-urlencoded'){
337 337
 					$body = $this->streamFactory->createStream(http_build_query($body, '', '&', PHP_QUERY_RFC1738));
338
-				}
339
-				elseif($contentType === 'application/json' || $contentType === 'application/vnd.api+json'){
338
+				} elseif($contentType === 'application/json' || $contentType === 'application/vnd.api+json'){
340 339
 					$body = $this->streamFactory->createStream(json_encode($body));
341 340
 				}
342
-			}
343
-			elseif(is_string($body)){
341
+			} elseif(is_string($body)){
344 342
 				// we don't check if the given string matches the content type - this is the implementor's responsibility
345 343
 				$body = $this->streamFactory->createStream($body);
346 344
 			}
Please login to merge, or discard this patch.