@@ -211,11 +211,11 @@ discard block |
||
| 211 | 211 | */ |
| 212 | 212 | public function __construct($response, $request, $requestOptions, $resourceClass) |
| 213 | 213 | {
|
| 214 | - if( ! $response instanceof Response) |
|
| 214 | + if (!$response instanceof Response) |
|
| 215 | 215 | {
|
| 216 | 216 | throw new IncorrectResponseTypeException('Request class didn\'t pass a response type into the response', 500);
|
| 217 | 217 | } |
| 218 | - if( ! $request instanceof Request) |
|
| 218 | + if (!$request instanceof Request) |
|
| 219 | 219 | {
|
| 220 | 220 | throw new IncorrectResponseTypeException('Request class didn\'t pass a request type into the response', 500);
|
| 221 | 221 | } |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | private function saveResponseBody() |
| 240 | 240 | {
|
| 241 | 241 | $body = $this->response->getBody()->getContents(); |
| 242 | - if(is_string($body)) |
|
| 242 | + if (is_string($body)) |
|
| 243 | 243 | {
|
| 244 | 244 | $body = json_decode($body, true); |
| 245 | 245 | } |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | $this->runTime = (double) $this->getHeaderFromResponse('X-Runtime');
|
| 290 | 290 | $this->xRequestID = $this->getHeaderFromResponse('X-Request-ID');
|
| 291 | 291 | |
| 292 | - if($this->responseContainsPagination()) |
|
| 292 | + if ($this->responseContainsPagination()) |
|
| 293 | 293 | {
|
| 294 | 294 | $this->hasPagination = true; |
| 295 | 295 | $this->recordsPerPage = (int) $this->getHeaderFromResponse('records_per_page');
|
@@ -320,7 +320,7 @@ discard block |
||
| 320 | 320 | */ |
| 321 | 321 | public function responseContainsPagination() |
| 322 | 322 | {
|
| 323 | - if( |
|
| 323 | + if ( |
|
| 324 | 324 | array_key_exists('records_per_page', $this->response->getHeaders())
|
| 325 | 325 | && |
| 326 | 326 | array_key_exists('total_records', $this->response->getHeaders())
|
@@ -361,7 +361,7 @@ discard block |
||
| 361 | 361 | private function parseResources() |
| 362 | 362 | {
|
| 363 | 363 | $resources = new ResourceCollection(); |
| 364 | - foreach($this->getRawData() as $resource) |
|
| 364 | + foreach ($this->getRawData() as $resource) |
|
| 365 | 365 | {
|
| 366 | 366 | $parsedResource = $this->parseResource($resource); |
| 367 | 367 | $resources->addResource($parsedResource); |
@@ -210,13 +210,13 @@ |
||
| 210 | 210 | */ |
| 211 | 211 | private $returnRequestClass = false; |
| 212 | 212 | |
| 213 | - /** |
|
| 214 | - * Response from UnionCloud |
|
| 215 | - * |
|
| 216 | - * This is populated by the $this->call() function |
|
| 217 | - * |
|
| 218 | - * @var BaseResponse |
|
| 219 | - */ |
|
| 213 | + /** |
|
| 214 | + * Response from UnionCloud |
|
| 215 | + * |
|
| 216 | + * This is populated by the $this->call() function |
|
| 217 | + * |
|
| 218 | + * @var BaseResponse |
|
| 219 | + */ |
|
| 220 | 220 | private $response; |
| 221 | 221 | |
| 222 | 222 | |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | */ |
| 263 | 263 | private function getChildInstance() |
| 264 | 264 | {
|
| 265 | - if(method_exists($this, 'getInstance')) |
|
| 265 | + if (method_exists($this, 'getInstance')) |
|
| 266 | 266 | {
|
| 267 | 267 | return $this->getInstance(); |
| 268 | 268 | } |
@@ -372,8 +372,8 @@ discard block |
||
| 372 | 372 | */ |
| 373 | 373 | public function setContentType($contentType) |
| 374 | 374 | {
|
| 375 | - if($contentType === 'json') { $contentType = 'application/json'; }
|
|
| 376 | - elseif($contentType === 'form') { $contentType = 'application/x-www-form-urlencoded'; }
|
|
| 375 | + if ($contentType === 'json') { $contentType = 'application/json'; }
|
|
| 376 | + elseif ($contentType === 'form') { $contentType = 'application/x-www-form-urlencoded'; }
|
|
| 377 | 377 | $this->contentType = $contentType; |
| 378 | 378 | } |
| 379 | 379 | |
@@ -396,11 +396,11 @@ discard block |
||
| 396 | 396 | * @param string $method |
| 397 | 397 | * @param array $body If you don't include it in a data array, we will |
| 398 | 398 | */ |
| 399 | - protected function setAPIParameters($endpoint,$method,$body) |
|
| 399 | + protected function setAPIParameters($endpoint, $method, $body) |
|
| 400 | 400 | {
|
| 401 | 401 | $this->setEndpoint($endpoint); |
| 402 | 402 | $this->setMethod($method); |
| 403 | - $this->setBody((array_key_exists('data', $body)?$body:array('data'=>$body)));
|
|
| 403 | + $this->setBody((array_key_exists('data', $body) ? $body : array('data'=>$body)));
|
|
| 404 | 404 | } |
| 405 | 405 | |
| 406 | 406 | |
@@ -452,7 +452,7 @@ discard block |
||
| 452 | 452 | // Create a client |
| 453 | 453 | $client = $this->createClient(); |
| 454 | 454 | |
| 455 | - try{
|
|
| 455 | + try {
|
|
| 456 | 456 | $request = new Request( |
| 457 | 457 | $this->getMethod(), |
| 458 | 458 | $this->getFullURL() |
@@ -465,11 +465,11 @@ discard block |
||
| 465 | 465 | } |
| 466 | 466 | |
| 467 | 467 | // Extract the history |
| 468 | - if( ! array_key_exists(0, $this->container)) |
|
| 468 | + if (!array_key_exists(0, $this->container)) |
|
| 469 | 469 | {
|
| 470 | 470 | throw new RequestHistoryNotFound('Request History wasn\'t recorded', 500);
|
| 471 | 471 | } |
| 472 | - try{
|
|
| 472 | + try {
|
|
| 473 | 473 | $this->debugRequest = $this->container[0]['request']; |
| 474 | 474 | $this->debugResponse = $this->container[0]['response']; |
| 475 | 475 | $this->requestOptions = $this->container[0]['options']; |
@@ -499,10 +499,10 @@ discard block |
||
| 499 | 499 | "Content-Type" => $this->getContentType(), |
| 500 | 500 | ], |
| 501 | 501 | 'http_errors' => true, |
| 502 | - 'verify' => __DIR__ . '/../../unioncloud.pem', |
|
| 502 | + 'verify' => __DIR__.'/../../unioncloud.pem', |
|
| 503 | 503 | 'debug' => false |
| 504 | 504 | ]; |
| 505 | - if($this->getContentType() === 'application/x-www-form-urlencoded') |
|
| 505 | + if ($this->getContentType() === 'application/x-www-form-urlencoded') |
|
| 506 | 506 | {
|
| 507 | 507 | $options['form_params'] = $this->getBody(); |
| 508 | 508 | } elseif ($this->getContentType() === 'application/json' && $this->getBody()) {
|
@@ -534,9 +534,9 @@ discard block |
||
| 534 | 534 | */ |
| 535 | 535 | private function getContentType() |
| 536 | 536 | {
|
| 537 | - if(!$this->contentType) |
|
| 537 | + if (!$this->contentType) |
|
| 538 | 538 | {
|
| 539 | - if($this->getMethod() === 'POST') { return 'application/x-www-form-urlencoded'; }
|
|
| 539 | + if ($this->getMethod() === 'POST') { return 'application/x-www-form-urlencoded'; }
|
|
| 540 | 540 | else { return 'application/json'; }
|
| 541 | 541 | } |
| 542 | 542 | return $this->contentType; |
@@ -593,7 +593,7 @@ discard block |
||
| 593 | 593 | private function getFullURL() |
| 594 | 594 | {
|
| 595 | 595 | $url = '/api/'.$this->getEndPoint(); |
| 596 | - if(($parameters = $this->getQueryParameters()) !== null) |
|
| 596 | + if (($parameters = $this->getQueryParameters()) !== null) |
|
| 597 | 597 | {
|
| 598 | 598 | $url .= '?'.http_build_query($parameters); |
| 599 | 599 | } |
@@ -620,15 +620,15 @@ discard block |
||
| 620 | 620 | $queryParameters = []; |
| 621 | 621 | |
| 622 | 622 | // Add parameters set through settings |
| 623 | - if($this->paginates) |
|
| 623 | + if ($this->paginates) |
|
| 624 | 624 | {
|
| 625 | 625 | $queryParameters['page'] = $this->page; |
| 626 | 626 | } |
| 627 | - if($this->useMode) |
|
| 627 | + if ($this->useMode) |
|
| 628 | 628 | {
|
| 629 | 629 | $queryParameters['mode'] = $this->mode; |
| 630 | 630 | } |
| 631 | - if(count($queryParameters) === 0) |
|
| 631 | + if (count($queryParameters) === 0) |
|
| 632 | 632 | {
|
| 633 | 633 | return null; |
| 634 | 634 | } |
@@ -679,7 +679,7 @@ discard block |
||
| 679 | 679 | */ |
| 680 | 680 | public function setPage($page) |
| 681 | 681 | {
|
| 682 | - if(!is_int($page)) |
|
| 682 | + if (!is_int($page)) |
|
| 683 | 683 | {
|
| 684 | 684 | throw new IncorrectRequestParameterException('Page must be an integer', 400);
|
| 685 | 685 | } |
@@ -718,7 +718,7 @@ discard block |
||
| 718 | 718 | */ |
| 719 | 719 | public function next() |
| 720 | 720 | {
|
| 721 | - if(! $this->response instanceof IResponse || $this->page >= $this->response->getTotalPages()) |
|
| 721 | + if (!$this->response instanceof IResponse || $this->page >= $this->response->getTotalPages()) |
|
| 722 | 722 | {
|
| 723 | 723 | throw new PageNotFoundException(); |
| 724 | 724 | } |
@@ -739,7 +739,7 @@ discard block |
||
| 739 | 739 | */ |
| 740 | 740 | public function previous() |
| 741 | 741 | {
|
| 742 | - if(! $this->response instanceof IResponse || $this->page <= 1) {
|
|
| 742 | + if (!$this->response instanceof IResponse || $this->page <= 1) {
|
|
| 743 | 743 | throw new PageNotFoundException(); |
| 744 | 744 | } |
| 745 | 745 | $this->minusPage(); |
@@ -764,7 +764,7 @@ discard block |
||
| 764 | 764 | $resourceCollection = new ResourceCollection(); |
| 765 | 765 | $resourceCollection->addResources($this->response->get()->toArray()); |
| 766 | 766 | $this->addPage(); |
| 767 | - while($this->page <= $this->response->getTotalPages()) |
|
| 767 | + while ($this->page <= $this->response->getTotalPages()) |
|
| 768 | 768 | {
|
| 769 | 769 | $this->call(); |
| 770 | 770 | $resourceCollection->addResources($this->response->get()->toArray()); |
@@ -846,11 +846,11 @@ discard block |
||
| 846 | 846 | */ |
| 847 | 847 | protected function getReturnDetails() |
| 848 | 848 | {
|
| 849 | - if($this->returnRequestClass) |
|
| 849 | + if ($this->returnRequestClass) |
|
| 850 | 850 | {
|
| 851 | 851 | return $this; |
| 852 | 852 | } else {
|
| 853 | - if(!$this->configuration->getDebug()) |
|
| 853 | + if (!$this->configuration->getDebug()) |
|
| 854 | 854 | {
|
| 855 | 855 | $this->response->removeDebugOptions(); |
| 856 | 856 | } |
@@ -879,7 +879,7 @@ discard block |
||
| 879 | 879 | */ |
| 880 | 880 | public function getResponse() |
| 881 | 881 | {
|
| 882 | - if( ! $this->response instanceof IResponse) |
|
| 882 | + if (!$this->response instanceof IResponse) |
|
| 883 | 883 | {
|
| 884 | 884 | throw new ResponseMustInheritIResponse(); |
| 885 | 885 | } |
@@ -372,8 +372,7 @@ discard block |
||
| 372 | 372 | */ |
| 373 | 373 | public function setContentType($contentType) |
| 374 | 374 | {
|
| 375 | - if($contentType === 'json') { $contentType = 'application/json'; }
|
|
| 376 | - elseif($contentType === 'form') { $contentType = 'application/x-www-form-urlencoded'; }
|
|
| 375 | + if($contentType === 'json') { $contentType = 'application/json'; } elseif($contentType === 'form') { $contentType = 'application/x-www-form-urlencoded'; }
|
|
| 377 | 376 | $this->contentType = $contentType; |
| 378 | 377 | } |
| 379 | 378 | |
@@ -536,8 +535,7 @@ discard block |
||
| 536 | 535 | {
|
| 537 | 536 | if(!$this->contentType) |
| 538 | 537 | {
|
| 539 | - if($this->getMethod() === 'POST') { return 'application/x-www-form-urlencoded'; }
|
|
| 540 | - else { return 'application/json'; }
|
|
| 538 | + if($this->getMethod() === 'POST') { return 'application/x-www-form-urlencoded'; } else { return 'application/json'; }
|
|
| 541 | 539 | } |
| 542 | 540 | return $this->contentType; |
| 543 | 541 | } |
@@ -84,7 +84,7 @@ |
||
| 84 | 84 | */ |
| 85 | 85 | public function first() |
| 86 | 86 | {
|
| 87 | - if(!isset($this->resources[0])) |
|
| 87 | + if (!isset($this->resources[0])) |
|
| 88 | 88 | {
|
| 89 | 89 | throw new ResourceNotFoundException('No resources were found.', 404);
|
| 90 | 90 | } |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | * |
| 25 | 25 | * @var int|null $unionCloudCode |
| 26 | 26 | */ |
| 27 | - protected $unionCloudCode=null; |
|
| 27 | + protected $unionCloudCode = null; |
|
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | 30 | * BaseUnionCloudException constructor. |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | * @param Throwable|null $previous |
| 37 | 37 | * @param int $unionCloudCode |
| 38 | 38 | */ |
| 39 | - public function __construct($message = "", $code = 0, Throwable $previous = null, $unionCloudCode=0) |
|
| 39 | + public function __construct($message = "", $code = 0, Throwable $previous = null, $unionCloudCode = 0) |
|
| 40 | 40 | {
|
| 41 | 41 | $this->unionCloudCode = $unionCloudCode; |
| 42 | 42 | parent::__construct($message, $code, $previous); |
@@ -24,7 +24,7 @@ |
||
| 24 | 24 | * @param Throwable|null $previous |
| 25 | 25 | * @param int $unionCloudCode |
| 26 | 26 | */ |
| 27 | - public function __construct($message, $code, Throwable $previous = null, $unionCloudCode=0) |
|
| 27 | + public function __construct($message, $code, Throwable $previous = null, $unionCloudCode = 0) |
|
| 28 | 28 | {
|
| 29 | 29 | parent::__construct($message, $code, $previous, $unionCloudCode); |
| 30 | 30 | } |
@@ -26,7 +26,7 @@ |
||
| 26 | 26 | * @param Throwable|null $previous |
| 27 | 27 | * @param int $unionCloudCode |
| 28 | 28 | */ |
| 29 | - public function __construct($message, $code, Throwable $previous = null, $unionCloudCode=0) |
|
| 29 | + public function __construct($message, $code, Throwable $previous = null, $unionCloudCode = 0) |
|
| 30 | 30 | {
|
| 31 | 31 | parent::__construct($message, $code, $previous, $unionCloudCode); |
| 32 | 32 | } |
@@ -25,7 +25,7 @@ |
||
| 25 | 25 | * @param Throwable|null $previous |
| 26 | 26 | * @param int $unionCloudCode |
| 27 | 27 | */ |
| 28 | - public function __construct($message = "", $code = 0, Throwable $previous = null, $unionCloudCode=0) |
|
| 28 | + public function __construct($message = "", $code = 0, Throwable $previous = null, $unionCloudCode = 0) |
|
| 29 | 29 | {
|
| 30 | 30 | parent::__construct($message, $code, $previous, $unionCloudCode); |
| 31 | 31 | } |
@@ -25,7 +25,7 @@ |
||
| 25 | 25 | * @param Throwable|null $previous |
| 26 | 26 | * @param int $unionCloudCode |
| 27 | 27 | */ |
| 28 | - public function __construct($message, $code, Throwable $previous = null, $unionCloudCode=0) |
|
| 28 | + public function __construct($message, $code, Throwable $previous = null, $unionCloudCode = 0) |
|
| 29 | 29 | { |
| 30 | 30 | parent::__construct($message, $code, $previous, $unionCloudCode); |
| 31 | 31 | } |
@@ -24,7 +24,7 @@ |
||
| 24 | 24 | * @param Throwable|null $previous |
| 25 | 25 | * @param int $unionCloudCode |
| 26 | 26 | */ |
| 27 | - public function __construct($message, $code, Throwable $previous = null, $unionCloudCode=0) |
|
| 27 | + public function __construct($message, $code, Throwable $previous = null, $unionCloudCode = 0) |
|
| 28 | 28 | { |
| 29 | 29 | parent::__construct($message, $code, $previous, $unionCloudCode); |
| 30 | 30 | } |