@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * @param string $type optional |
32 | 32 | * @param string|int $id optional |
33 | 33 | */ |
34 | - public function __construct($type=null, $id=null) { |
|
34 | + public function __construct($type = null, $id = null) { |
|
35 | 35 | $this->validator = new Validator(); |
36 | 36 | |
37 | 37 | if ($type !== null) { |
@@ -42,9 +42,9 @@ discard block |
||
42 | 42 | } |
43 | 43 | |
44 | 44 | // always mark as used, as these keys are reserved |
45 | - $this->validator->claimUsedFields($fieldNames=['type'], Validator::OBJECT_CONTAINER_TYPE); |
|
46 | - $this->validator->claimUsedFields($fieldNames=['id'], Validator::OBJECT_CONTAINER_ID); |
|
47 | - $this->validator->claimUsedFields($fieldNames=['lid'], Validator::OBJECT_CONTAINER_LID); |
|
45 | + $this->validator->claimUsedFields($fieldNames = ['type'], Validator::OBJECT_CONTAINER_TYPE); |
|
46 | + $this->validator->claimUsedFields($fieldNames = ['id'], Validator::OBJECT_CONTAINER_ID); |
|
47 | + $this->validator->claimUsedFields($fieldNames = ['lid'], Validator::OBJECT_CONTAINER_LID); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | /** |
220 | 220 | * @inheritDoc |
221 | 221 | */ |
222 | - public function getResource($identifierOnly=false) { |
|
222 | + public function getResource($identifierOnly = false) { |
|
223 | 223 | return $this; |
224 | 224 | } |
225 | 225 |
@@ -70,6 +70,6 @@ |
||
70 | 70 | * @deprecated {@see prepareContentType()} |
71 | 71 | */ |
72 | 72 | public static function mergeProfilesInContentType($contentType, array $profiles) { |
73 | - return self::prepareContentType($contentType, $extensions=[], $profiles); |
|
73 | + return self::prepareContentType($contentType, $extensions = [], $profiles); |
|
74 | 74 | } |
75 | 75 | } |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * @param string $specificAboutLink optional, human-friendly explanation of the specific error |
50 | 50 | * @param string $genericTypeLink optional, human-friendly explanation of the generic type of error |
51 | 51 | */ |
52 | - public function __construct($genericCode=null, $genericTitle=null, $specificDetails=null, $specificAboutLink=null, $genericTypeLink=null) { |
|
52 | + public function __construct($genericCode = null, $genericTitle = null, $specificDetails = null, $specificAboutLink = null, $genericTypeLink = null) { |
|
53 | 53 | if ($genericCode !== null) { |
54 | 54 | $this->setApplicationCode($genericCode); |
55 | 55 | } |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * |
70 | 70 | * @throws InputException if $exception is not \Exception or \Throwable |
71 | 71 | */ |
72 | - public static function fromException($exception, array $options=[]) { |
|
72 | + public static function fromException($exception, array $options = []) { |
|
73 | 73 | if ($exception instanceof \Exception === false && $exception instanceof \Throwable === false) { |
74 | 74 | throw new InputException('input is not a real exception in php5 or php7'); |
75 | 75 | } |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | * @param string $specificAboutLink optional, explanation of the specific error |
129 | 129 | * @param string $genericTypeLink optional, explanation of the generic type of error |
130 | 130 | */ |
131 | - public function setHumanExplanation($genericTitle, $specificDetails=null, $specificAboutLink=null, $genericTypeLink=null) { |
|
131 | + public function setHumanExplanation($genericTitle, $specificDetails = null, $specificAboutLink = null, $genericTypeLink = null) { |
|
132 | 132 | $this->setHumanTitle($genericTitle); |
133 | 133 | |
134 | 134 | if ($specificDetails !== null) { |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | * @param string $href |
149 | 149 | * @param array $meta optional, if given a LinkObject is added, otherwise a link string is added |
150 | 150 | */ |
151 | - public function setAboutLink($href, array $meta=[]) { |
|
151 | + public function setAboutLink($href, array $meta = []) { |
|
152 | 152 | $this->addLink('about', $href, $meta); |
153 | 153 | } |
154 | 154 | |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | * @param string $href |
159 | 159 | * @param array $meta optional, if given a LinkObject is added, otherwise a link string is added |
160 | 160 | */ |
161 | - public function setTypeLink($href, array $meta=[]) { |
|
161 | + public function setTypeLink($href, array $meta = []) { |
|
162 | 162 | $this->addLink('type', $href, $meta); |
163 | 163 | } |
164 | 164 | |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | * @param string $href |
171 | 171 | * @param array $meta optional, if given a LinkObject is added, otherwise a link string is added |
172 | 172 | */ |
173 | - public function appendTypeLink($href, array $meta=[]) { |
|
173 | + public function appendTypeLink($href, array $meta = []) { |
|
174 | 174 | $this->appendLink('type', $href, $meta); |
175 | 175 | } |
176 | 176 |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | * @param int $exactTotal optional |
99 | 99 | * @param int $bestGuessTotal optional |
100 | 100 | */ |
101 | - public function setCount(PaginableInterface $paginable, $exactTotal=null, $bestGuessTotal=null) { |
|
101 | + public function setCount(PaginableInterface $paginable, $exactTotal = null, $bestGuessTotal = null) { |
|
102 | 102 | $this->setPaginationMeta($paginable, $exactTotal, $bestGuessTotal); |
103 | 103 | } |
104 | 104 | |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | ]; |
192 | 192 | |
193 | 193 | if ($resource instanceof ResourceDocument) { |
194 | - $resource->addMeta('page', $metadata, $level=Document::LEVEL_RESOURCE); |
|
194 | + $resource->addMeta('page', $metadata, $level = Document::LEVEL_RESOURCE); |
|
195 | 195 | } |
196 | 196 | else { |
197 | 197 | $resource->addMeta('page', $metadata); |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | * @param int $bestGuessTotal optional |
214 | 214 | * @param boolean $rangeIsTruncated optional, if both after and before are supplied but the items exceed requested or max size |
215 | 215 | */ |
216 | - public function setPaginationMeta(PaginableInterface $paginable, $exactTotal=null, $bestGuessTotal=null, $rangeIsTruncated=null) { |
|
216 | + public function setPaginationMeta(PaginableInterface $paginable, $exactTotal = null, $bestGuessTotal = null, $rangeIsTruncated = null) { |
|
217 | 217 | $metadata = []; |
218 | 218 | |
219 | 219 | if ($exactTotal !== null) { |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | * @param string $specificDetails optional |
247 | 247 | * @return ErrorObject |
248 | 248 | */ |
249 | - public function getUnsupportedSortErrorObject($genericTitle=null, $specificDetails=null) { |
|
249 | + public function getUnsupportedSortErrorObject($genericTitle = null, $specificDetails = null) { |
|
250 | 250 | $errorObject = new ErrorObject('Unsupported sort'); |
251 | 251 | $errorObject->setTypeLink('https://jsonapi.org/profiles/ethanresnick/cursor-pagination/unsupported-sort'); |
252 | 252 | $errorObject->blameQueryParameter('sort'); |
@@ -276,12 +276,12 @@ discard block |
||
276 | 276 | * @param string $specificDetails optional, e.g. 'You requested a size of 200, but 100 is the maximum.' |
277 | 277 | * @return ErrorObject |
278 | 278 | */ |
279 | - public function getMaxPageSizeExceededErrorObject($maxSize, $genericTitle=null, $specificDetails=null) { |
|
279 | + public function getMaxPageSizeExceededErrorObject($maxSize, $genericTitle = null, $specificDetails = null) { |
|
280 | 280 | $errorObject = new ErrorObject('Max page size exceeded'); |
281 | 281 | $errorObject->setTypeLink('https://jsonapi.org/profiles/ethanresnick/cursor-pagination/max-size-exceeded'); |
282 | 282 | $errorObject->blameQueryParameter('page[size]'); |
283 | 283 | $errorObject->setHttpStatusCode(400); |
284 | - $errorObject->addMeta('page', $value=['maxSize' => $maxSize]); |
|
284 | + $errorObject->addMeta('page', $value = ['maxSize' => $maxSize]); |
|
285 | 285 | |
286 | 286 | if ($genericTitle !== null) { |
287 | 287 | $errorObject->setHumanExplanation($genericTitle, $specificDetails); |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | * @param string $specificDetails optional, e.g. 'page[size] must be a positive integer; got 0' |
308 | 308 | * @return ErrorObject |
309 | 309 | */ |
310 | - public function getInvalidParameterValueErrorObject($queryParameter, $typeLink=null, $genericTitle=null, $specificDetails=null) { |
|
310 | + public function getInvalidParameterValueErrorObject($queryParameter, $typeLink = null, $genericTitle = null, $specificDetails = null) { |
|
311 | 311 | $errorObject = new ErrorObject('Invalid parameter value'); |
312 | 312 | $errorObject->blameQueryParameter($queryParameter); |
313 | 313 | $errorObject->setHttpStatusCode(400); |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | * @param string $specificDetails optional |
336 | 336 | * @return ErrorObject |
337 | 337 | */ |
338 | - public function getRangePaginationNotSupportedErrorObject($genericTitle=null, $specificDetails=null) { |
|
338 | + public function getRangePaginationNotSupportedErrorObject($genericTitle = null, $specificDetails = null) { |
|
339 | 339 | $errorObject = new ErrorObject('Range pagination not supported'); |
340 | 340 | $errorObject->setTypeLink('https://jsonapi.org/profiles/ethanresnick/cursor-pagination/range-pagination-not-supported'); |
341 | 341 | $errorObject->setHttpStatusCode(400); |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | /** |
53 | 53 | * encode to json with these default options |
54 | 54 | */ |
55 | - 'encodeOptions' => JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE, |
|
55 | + 'encodeOptions' => JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE, |
|
56 | 56 | |
57 | 57 | /** |
58 | 58 | * encode to human-readable json, useful when debugging |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | * |
99 | 99 | * @throws InputException if the $level is Document::LEVEL_JSONAPI, Document::LEVEL_RESOURCE, or unknown |
100 | 100 | */ |
101 | - public function addLink($key, $href, array $meta=[], $level=Document::LEVEL_ROOT) { |
|
101 | + public function addLink($key, $href, array $meta = [], $level = Document::LEVEL_ROOT) { |
|
102 | 102 | if ($level === Document::LEVEL_ROOT) { |
103 | 103 | $this->linkManagerAddLink($key, $href, $meta); |
104 | 104 | } |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | * @param array $meta optional, if given a LinkObject is added, otherwise a link string is added |
123 | 123 | * @param string $level one of the Document::LEVEL_* constants, optional, defaults to Document::LEVEL_ROOT |
124 | 124 | */ |
125 | - public function setSelfLink($href, array $meta=[], $level=Document::LEVEL_ROOT) { |
|
125 | + public function setSelfLink($href, array $meta = [], $level = Document::LEVEL_ROOT) { |
|
126 | 126 | if ($level === Document::LEVEL_ROOT && ($this->extensions !== [] || $this->profiles !== [])) { |
127 | 127 | $contentType = Converter::prepareContentType(Document::CONTENT_TYPE_OFFICIAL, $this->extensions, $this->profiles); |
128 | 128 | |
@@ -146,8 +146,8 @@ discard block |
||
146 | 146 | * @param string $href |
147 | 147 | * @param array $meta optional, if given a LinkObject is added, otherwise a link string is added |
148 | 148 | */ |
149 | - public function setDescribedByLink($href, array $meta=[]) { |
|
150 | - $this->addLink('describedby', $href, $meta, $level=Document::LEVEL_ROOT); |
|
149 | + public function setDescribedByLink($href, array $meta = []) { |
|
150 | + $this->addLink('describedby', $href, $meta, $level = Document::LEVEL_ROOT); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | /** |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | * @throws InputException if the $level is unknown |
159 | 159 | * @throws InputException if the $level is Document::LEVEL_RESOURCE |
160 | 160 | */ |
161 | - public function addMeta($key, $value, $level=Document::LEVEL_ROOT) { |
|
161 | + public function addMeta($key, $value, $level = Document::LEVEL_ROOT) { |
|
162 | 162 | if ($level === Document::LEVEL_ROOT) { |
163 | 163 | if ($this->meta === null) { |
164 | 164 | $this->setMetaObject(new MetaObject()); |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | /** |
289 | 289 | * @inheritDoc |
290 | 290 | */ |
291 | - public function toJson(array $options=[]) { |
|
291 | + public function toJson(array $options = []) { |
|
292 | 292 | $options = array_merge(self::$defaults, $options); |
293 | 293 | |
294 | 294 | $array = ($options['array'] !== null) ? $options['array'] : $this->toArray(); |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | /** |
313 | 313 | * @inheritDoc |
314 | 314 | */ |
315 | - public function sendResponse(array $options=[]) { |
|
315 | + public function sendResponse(array $options = []) { |
|
316 | 316 | $options = array_merge(self::$defaults, $options); |
317 | 317 | |
318 | 318 | if ($this->httpStatusCode === 204) { |