@@ -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 |
@@ -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 | |
@@ -132,8 +132,8 @@ discard block |
||
132 | 132 | * @param string $href |
133 | 133 | * @param array $meta optional, if given a LinkObject is added, otherwise a link string is added |
134 | 134 | */ |
135 | - public function setDescribedByLink($href, array $meta=[]) { |
|
136 | - $this->addLink('describedby', $href, $meta, $level=Document::LEVEL_ROOT); |
|
135 | + public function setDescribedByLink($href, array $meta = []) { |
|
136 | + $this->addLink('describedby', $href, $meta, $level = Document::LEVEL_ROOT); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | * @throws InputException if the $level is unknown |
145 | 145 | * @throws InputException if the $level is Document::LEVEL_RESOURCE |
146 | 146 | */ |
147 | - public function addMeta($key, $value, $level=Document::LEVEL_ROOT) { |
|
147 | + public function addMeta($key, $value, $level = Document::LEVEL_ROOT) { |
|
148 | 148 | if ($level === Document::LEVEL_ROOT) { |
149 | 149 | if ($this->meta === null) { |
150 | 150 | $this->setMetaObject(new MetaObject()); |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | /** |
246 | 246 | * @inheritDoc |
247 | 247 | */ |
248 | - public function toJson(array $options=[]) { |
|
248 | + public function toJson(array $options = []) { |
|
249 | 249 | $options = array_merge(self::$defaults, $options); |
250 | 250 | |
251 | 251 | $array = ($options['array'] !== null) ? $options['array'] : $this->toArray(); |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | /** |
270 | 270 | * @inheritDoc |
271 | 271 | */ |
272 | - public function sendResponse(array $options=[]) { |
|
272 | + public function sendResponse(array $options = []) { |
|
273 | 273 | $options = array_merge(self::$defaults, $options); |
274 | 274 | |
275 | 275 | if ($this->httpStatusCode === 204) { |
@@ -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); |