@@ -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 |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | /** |
47 | 47 | * encode to json with these default options |
48 | 48 | */ |
49 | - 'encodeOptions' => JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE, |
|
49 | + 'encodeOptions' => JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE, |
|
50 | 50 | |
51 | 51 | /** |
52 | 52 | * encode to human-readable json, useful when debugging |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | * |
93 | 93 | * @throws InputException if the $level is Document::LEVEL_JSONAPI, Document::LEVEL_RESOURCE, or unknown |
94 | 94 | */ |
95 | - public function addLink($key, $href, array $meta=[], $level=Document::LEVEL_ROOT) { |
|
95 | + public function addLink($key, $href, array $meta = [], $level = Document::LEVEL_ROOT) { |
|
96 | 96 | if ($level === Document::LEVEL_ROOT) { |
97 | 97 | if ($this->links === null) { |
98 | 98 | $this->setLinksObject(new LinksObject()); |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | * @param array $meta optional, if given a LinkObject is added, otherwise a link string is added |
119 | 119 | * @param string $level one of the Document::LEVEL_* constants, optional, defaults to Document::LEVEL_ROOT |
120 | 120 | */ |
121 | - public function setSelfLink($href, array $meta=[], $level=Document::LEVEL_ROOT) { |
|
121 | + public function setSelfLink($href, array $meta = [], $level = Document::LEVEL_ROOT) { |
|
122 | 122 | $this->addLink('self', $href, $meta, $level); |
123 | 123 | } |
124 | 124 | |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | * @throws InputException if the $level is unknown |
131 | 131 | * @throws InputException if the $level is Document::LEVEL_RESOURCE |
132 | 132 | */ |
133 | - public function addMeta($key, $value, $level=Document::LEVEL_ROOT) { |
|
133 | + public function addMeta($key, $value, $level = Document::LEVEL_ROOT) { |
|
134 | 134 | if ($level === Document::LEVEL_ROOT) { |
135 | 135 | if ($this->meta === null) { |
136 | 136 | $this->setMetaObject(new MetaObject()); |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | /** |
232 | 232 | * @inheritDoc |
233 | 233 | */ |
234 | - public function toJson(array $options=[]) { |
|
234 | + public function toJson(array $options = []) { |
|
235 | 235 | $options = array_merge(self::$defaults, $options); |
236 | 236 | |
237 | 237 | $array = ($options['array'] !== null) ? $options['array'] : $this->toArray(); |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | /** |
256 | 256 | * @inheritDoc |
257 | 257 | */ |
258 | - public function sendResponse(array $options=[]) { |
|
258 | + public function sendResponse(array $options = []) { |
|
259 | 259 | $options = array_merge(self::$defaults, $options); |
260 | 260 | |
261 | 261 | if ($this->httpStatusCode === 204) { |
@@ -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 | } |