@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | * @param int $exactTotal optional |
| 100 | 100 | * @param int $bestGuessTotal optional |
| 101 | 101 | */ |
| 102 | - public function setCount(PaginableInterface $paginable, $exactTotal=null, $bestGuessTotal=null) { |
|
| 102 | + public function setCount(PaginableInterface $paginable, $exactTotal = null, $bestGuessTotal = null) { |
|
| 103 | 103 | $this->setPaginationMeta($paginable, $exactTotal, $bestGuessTotal); |
| 104 | 104 | } |
| 105 | 105 | |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | ]; |
| 193 | 193 | |
| 194 | 194 | if ($resource instanceof ResourceDocument) { |
| 195 | - $resource->addMeta($this->getKeyword('page'), $metadata, $level=Document::LEVEL_RESOURCE); |
|
| 195 | + $resource->addMeta($this->getKeyword('page'), $metadata, $level = Document::LEVEL_RESOURCE); |
|
| 196 | 196 | } |
| 197 | 197 | else { |
| 198 | 198 | $resource->addMeta($this->getKeyword('page'), $metadata); |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | * @param int $bestGuessTotal optional |
| 215 | 215 | * @param boolean $rangeIsTruncated optional, if both after and before are supplied but the items exceed requested or max size |
| 216 | 216 | */ |
| 217 | - public function setPaginationMeta(PaginableInterface $paginable, $exactTotal=null, $bestGuessTotal=null, $rangeIsTruncated=null) { |
|
| 217 | + public function setPaginationMeta(PaginableInterface $paginable, $exactTotal = null, $bestGuessTotal = null, $rangeIsTruncated = null) { |
|
| 218 | 218 | $metadata = []; |
| 219 | 219 | |
| 220 | 220 | if ($exactTotal !== null) { |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | * @param string $specificDetails optional |
| 248 | 248 | * @return ErrorObject |
| 249 | 249 | */ |
| 250 | - public function getUnsupportedSortErrorObject($genericTitle=null, $specificDetails=null) { |
|
| 250 | + public function getUnsupportedSortErrorObject($genericTitle = null, $specificDetails = null) { |
|
| 251 | 251 | $errorObject = new ErrorObject('Unsupported sort'); |
| 252 | 252 | $errorObject->appendTypeLink('https://jsonapi.org/profiles/ethanresnick/cursor-pagination/unsupported-sort'); |
| 253 | 253 | $errorObject->blameQueryParameter('sort'); |
@@ -277,12 +277,12 @@ discard block |
||
| 277 | 277 | * @param string $specificDetails optional, e.g. 'You requested a size of 200, but 100 is the maximum.' |
| 278 | 278 | * @return ErrorObject |
| 279 | 279 | */ |
| 280 | - public function getMaxPageSizeExceededErrorObject($maxSize, $genericTitle=null, $specificDetails=null) { |
|
| 280 | + public function getMaxPageSizeExceededErrorObject($maxSize, $genericTitle = null, $specificDetails = null) { |
|
| 281 | 281 | $errorObject = new ErrorObject('Max page size exceeded'); |
| 282 | 282 | $errorObject->appendTypeLink('https://jsonapi.org/profiles/ethanresnick/cursor-pagination/max-size-exceeded'); |
| 283 | 283 | $errorObject->blameQueryParameter($this->getKeyword('page').'[size]'); |
| 284 | 284 | $errorObject->setHttpStatusCode(400); |
| 285 | - $errorObject->addMeta($this->getKeyword('page'), $value=['maxSize' => $maxSize]); |
|
| 285 | + $errorObject->addMeta($this->getKeyword('page'), $value = ['maxSize' => $maxSize]); |
|
| 286 | 286 | |
| 287 | 287 | if ($genericTitle !== null) { |
| 288 | 288 | $errorObject->setHumanExplanation($genericTitle, $specificDetails); |
@@ -308,7 +308,7 @@ discard block |
||
| 308 | 308 | * @param string $specificDetails optional, e.g. 'page[size] must be a positive integer; got 0' |
| 309 | 309 | * @return ErrorObject |
| 310 | 310 | */ |
| 311 | - public function getInvalidParameterValueErrorObject($queryParameter, $typeLink=null, $genericTitle=null, $specificDetails=null) { |
|
| 311 | + public function getInvalidParameterValueErrorObject($queryParameter, $typeLink = null, $genericTitle = null, $specificDetails = null) { |
|
| 312 | 312 | $errorObject = new ErrorObject('Invalid parameter value'); |
| 313 | 313 | $errorObject->blameQueryParameter($queryParameter); |
| 314 | 314 | $errorObject->setHttpStatusCode(400); |
@@ -336,7 +336,7 @@ discard block |
||
| 336 | 336 | * @param string $specificDetails optional |
| 337 | 337 | * @return ErrorObject |
| 338 | 338 | */ |
| 339 | - public function getRangePaginationNotSupportedErrorObject($genericTitle=null, $specificDetails=null) { |
|
| 339 | + public function getRangePaginationNotSupportedErrorObject($genericTitle = null, $specificDetails = null) { |
|
| 340 | 340 | $errorObject = new ErrorObject('Range pagination not supported'); |
| 341 | 341 | $errorObject->appendTypeLink('https://jsonapi.org/profiles/ethanresnick/cursor-pagination/range-pagination-not-supported'); |
| 342 | 342 | $errorObject->setHttpStatusCode(400); |
@@ -5,7 +5,7 @@ |
||
| 5 | 5 | use alsvanzelf\jsonapi\exceptions\Exception; |
| 6 | 6 | |
| 7 | 7 | class DuplicateException extends Exception { |
| 8 | - public function __construct($message='', $code=409, $previous=null) { |
|
| 8 | + public function __construct($message = '', $code = 409, $previous = null) { |
|
| 9 | 9 | return parent::__construct($message, $code, $previous); |
| 10 | 10 | } |
| 11 | 11 | } |
@@ -5,7 +5,7 @@ |
||
| 5 | 5 | use alsvanzelf\jsonapi\exceptions\Exception; |
| 6 | 6 | |
| 7 | 7 | class InputException extends Exception { |
| 8 | - public function __construct($message='', $code=400, $previous=null) { |
|
| 8 | + public function __construct($message = '', $code = 400, $previous = null) { |
|
| 9 | 9 | return parent::__construct($message, $code, $previous); |
| 10 | 10 | } |
| 11 | 11 | } |
@@ -43,7 +43,7 @@ |
||
| 43 | 43 | * @param mixed $value |
| 44 | 44 | * @param string $level one of the Document::LEVEL_* constants, optional, defaults to Document::LEVEL_ROOT |
| 45 | 45 | */ |
| 46 | - public function add($key, $value, $level=Document::LEVEL_ROOT) { |
|
| 46 | + public function add($key, $value, $level = Document::LEVEL_ROOT) { |
|
| 47 | 47 | parent::addMeta($key, $value, $level); |
| 48 | 48 | } |
| 49 | 49 | |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | * @param string|int $id |
| 55 | 55 | * @param array $attributes optional, if given a ResourceObject is added, otherwise a ResourceIdentifierObject is added |
| 56 | 56 | */ |
| 57 | - public function add($type, $id, array $attributes=[]) { |
|
| 57 | + public function add($type, $id, array $attributes = []) { |
|
| 58 | 58 | if ($attributes === []) { |
| 59 | 59 | $this->addResource(new ResourceIdentifierObject($type, $id)); |
| 60 | 60 | } |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | /** |
| 67 | 67 | * @inheritDoc |
| 68 | 68 | */ |
| 69 | - public function setPaginationLinks($previousHref=null, $nextHref=null, $firstHref=null, $lastHref=null) { |
|
| 69 | + public function setPaginationLinks($previousHref = null, $nextHref = null, $firstHref = null, $lastHref = null) { |
|
| 70 | 70 | if ($previousHref !== null) { |
| 71 | 71 | $this->addLink('prev', $previousHref); |
| 72 | 72 | } |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | * |
| 96 | 96 | * @throws InputException if the resource is empty |
| 97 | 97 | */ |
| 98 | - public function addResource(ResourceInterface $resource, array $options=[]) { |
|
| 98 | + public function addResource(ResourceInterface $resource, array $options = []) { |
|
| 99 | 99 | if ($resource->getResource()->isEmpty()) { |
| 100 | 100 | throw new InputException('does not make sense to add empty resources to a collection'); |
| 101 | 101 | } |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | /** |
| 21 | 21 | * @inheritDoc |
| 22 | 22 | */ |
| 23 | - public function __construct(array $aliases=[]) { |
|
| 23 | + public function __construct(array $aliases = []) { |
|
| 24 | 24 | $officialKeywords = $this->getOfficialKeywords(); |
| 25 | 25 | if ($officialKeywords === []) { |
| 26 | 26 | return; |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | if ($alias === $keyword) { |
| 36 | 36 | throw new InputException('an alias should be different from its keyword'); |
| 37 | 37 | } |
| 38 | - if (in_array($keyword, $officialKeywords, $strict=true) === false) { |
|
| 38 | + if (in_array($keyword, $officialKeywords, $strict = true) === false) { |
|
| 39 | 39 | throw new InputException('unknown keyword "'.$keyword.'" to alias'); |
| 40 | 40 | } |
| 41 | 41 | Validator::checkMemberName($alias); |
@@ -40,7 +40,7 @@ |
||
| 40 | 40 | * |
| 41 | 41 | * @throws DuplicateException |
| 42 | 42 | */ |
| 43 | - public function claimUsedFields(array $fieldNames, $objectContainer, array $options=[]) { |
|
| 43 | + public function claimUsedFields(array $fieldNames, $objectContainer, array $options = []) { |
|
| 44 | 44 | $options = array_merge(self::$defaults, $options); |
| 45 | 45 | |
| 46 | 46 | foreach ($fieldNames as $fieldName) { |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | * @param string $href |
| 22 | 22 | * @param array $meta optional, if given a LinkObject is added, otherwise a link string is added |
| 23 | 23 | */ |
| 24 | - public function addLink($key, $href, array $meta=[]) { |
|
| 24 | + public function addLink($key, $href, array $meta = []) { |
|
| 25 | 25 | $this->ensureLinksObject(); |
| 26 | 26 | $this->links->add($key, $href, $meta); |
| 27 | 27 | } |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | * @param string $href |
| 34 | 34 | * @param array $meta optional, if given a LinkObject is added, otherwise a link string is added |
| 35 | 35 | */ |
| 36 | - public function appendLink($key, $href, array $meta=[]) { |
|
| 36 | + public function appendLink($key, $href, array $meta = []) { |
|
| 37 | 37 | $this->ensureLinksObject(); |
| 38 | 38 | $this->links->append($key, $href, $meta); |
| 39 | 39 | } |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | * @param array $queryParameters all query parameters defined by the specification |
| 37 | 37 | * @param array $document the request jsonapi document |
| 38 | 38 | */ |
| 39 | - public function __construct($selfLink='', array $queryParameters=[], array $document=[]) { |
|
| 39 | + public function __construct($selfLink = '', array $queryParameters = [], array $document = []) { |
|
| 40 | 40 | $this->selfLink = $selfLink; |
| 41 | 41 | $this->queryParameters = $queryParameters; |
| 42 | 42 | $this->document = $document; |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | $document = $_POST; |
| 57 | 57 | if ($document === [] && isset($_SERVER['CONTENT_TYPE'])) { |
| 58 | 58 | $documentIsJsonapi = (strpos($_SERVER['CONTENT_TYPE'], Document::CONTENT_TYPE_OFFICIAL) !== false); |
| 59 | - $documentIsJson = (strpos($_SERVER['CONTENT_TYPE'], Document::CONTENT_TYPE_DEBUG) !== false); |
|
| 59 | + $documentIsJson = (strpos($_SERVER['CONTENT_TYPE'], Document::CONTENT_TYPE_DEBUG) !== false); |
|
| 60 | 60 | |
| 61 | 61 | if ($documentIsJsonapi || $documentIsJson) { |
| 62 | 62 | $document = json_decode(file_get_contents('php://input'), true); |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | * @param array $options optional {@see RequestParser::$defaults} |
| 127 | 127 | * @return string[]|array |
| 128 | 128 | */ |
| 129 | - public function getIncludePaths(array $options=[]) { |
|
| 129 | + public function getIncludePaths(array $options = []) { |
|
| 130 | 130 | $includePaths = explode(',', $this->queryParameters['include']); |
| 131 | 131 | |
| 132 | 132 | $options = array_merge(self::$defaults, $options); |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | * @var string $order one of the RequestParser::SORT_* constants |
| 192 | 192 | * } |
| 193 | 193 | */ |
| 194 | - public function getSortFields(array $options=[]) { |
|
| 194 | + public function getSortFields(array $options = []) { |
|
| 195 | 195 | $fields = explode(',', $this->queryParameters['sort']); |
| 196 | 196 | |
| 197 | 197 | $options = array_merge(self::$defaults, $options); |