|
11 | 11 | * setting all options |
12 | 12 | */ |
13 | 13 |
|
14 | | -$errorHumanApi = new ErrorObject($genericCode='Invalid input', $genericTitle='Too much options', $specificDetails='Please, choose a bit less. Consult your ...', $specificAboutLink='https://www.example.com/explanation.html', $genericTypeLink='https://www.example.com/documentation.html'); |
| 14 | +$errorHumanApi = new ErrorObject(genericCode: 'Invalid input', genericTitle: 'Too much options', specificDetails: 'Please, choose a bit less. Consult your ...', specificAboutLink: 'https://www.example.com/explanation.html', genericTypeLink: 'https://www.example.com/documentation.html'); |
15 | 15 |
|
16 | 16 | $errorSpecApi = new ErrorObject(); |
17 | 17 |
|
18 | 18 | // mark the cause of the error |
19 | | -$errorSpecApi->blameJsonPointer($pointer='/data/attributes/title'); |
20 | | -$errorSpecApi->blameQueryParameter($parameter='filter'); |
21 | | -$errorSpecApi->blameHeader($headerName='X-Foo'); |
| 19 | +$errorSpecApi->blameJsonPointer(pointer: '/data/attributes/title'); |
| 20 | +$errorSpecApi->blameQueryParameter(parameter: 'filter'); |
| 21 | +$errorSpecApi->blameHeader(headerName: 'X-Foo'); |
22 | 22 |
|
23 | 23 | // an identifier useful for helpdesk purposes |
24 | | -$errorSpecApi->setUniqueIdentifier($id=42); |
| 24 | +$errorSpecApi->setUniqueIdentifier(id: 42); |
25 | 25 |
|
26 | 26 | // add meta data as you would on a normal json response |
27 | | -$errorSpecApi->addMeta($key='foo', $value='bar'); |
| 27 | +$errorSpecApi->addMeta(key: 'foo', value: 'bar'); |
28 | 28 |
|
29 | 29 | // or as object |
30 | 30 | $metaObject = new \stdClass(); |
31 | 31 | $metaObject->property = 'value'; |
32 | | -$errorSpecApi->addMeta($key='object', $metaObject); |
| 32 | +$errorSpecApi->addMeta(key: 'object', value: $metaObject); |
33 | 33 |
|
34 | 34 | // the http status code |
35 | 35 | // @note it is better to set this on the jsonapi\errors object .. |
36 | 36 | // .. as only a single one can be consumed by the browser |
37 | | -$errorSpecApi->setHttpStatusCode($httpStatusCode=404); |
| 37 | +$errorSpecApi->setHttpStatusCode(httpStatusCode: 404); |
38 | 38 |
|
39 | 39 | // if not set during construction, set them here |
40 | | -$errorSpecApi->setApplicationCode($genericCode='Invalid input'); |
41 | | -$errorSpecApi->setHumanTitle($genericTitle='Too much options'); |
42 | | -$errorSpecApi->setHumanDetails($specificDetails='Please, choose a bit less. Consult your ...'); |
43 | | -$errorSpecApi->setAboutLink($specificAboutLink='https://www.example.com/explanation.html', ['foo'=>'bar']); |
44 | | -$errorSpecApi->setTypeLink($genericTypeLink='https://www.example.com/documentation.html', ['foo'=>'bar']); |
| 40 | +$errorSpecApi->setApplicationCode(genericCode: 'Invalid input'); |
| 41 | +$errorSpecApi->setHumanTitle(genericTitle: 'Too much options'); |
| 42 | +$errorSpecApi->setHumanDetails(specificDetails: 'Please, choose a bit less. Consult your ...'); |
| 43 | +$errorSpecApi->setAboutLink(href: 'https://www.example.com/explanation.html', meta: ['foo'=>'bar']); |
| 44 | +$errorSpecApi->setTypeLink(href: 'https://www.example.com/documentation.html', meta: ['foo'=>'bar']); |
45 | 45 |
|
46 | 46 | /** |
47 | 47 | * prepare multiple error objects for the errors response |
|
68 | 68 | $document->addErrorObject($errorSpecApi); |
69 | 69 | $document->addErrorObject($anotherError); |
70 | 70 | $document->addException($someException); |
71 | | -$document->add($genericCode='Authentication error', $genericTitle='Not logged in'); |
| 71 | +$document->add(genericCode: 'Authentication error', genericTitle: 'Not logged in'); |
72 | 72 | $document->addLink('redirect', '/login', ['label'=>'Log in']); |
73 | 73 |
|
74 | 74 | $document->setHttpStatusCode(400); |
|
0 commit comments