You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/exception-introduction.md
+25Lines changed: 25 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,6 +13,31 @@ try {
13
13
}
14
14
```
15
15
16
+
## InputException
17
+
18
+
The `Art4\JsonApiClient\Exception\InputException` will be thrown if the input for `Art4\JsonApiClient\Input\RequestStringInput` or `Art4\JsonApiClient\Input\ResponseStringInput` is not a string or not valid JSON.
19
+
20
+
```php
21
+
use Art4\JsonApiClient\Exception\InputException;
22
+
use Art4\JsonApiClient\Input\RequestStringInput;
23
+
24
+
// If input is not a string
25
+
try {
26
+
$input = new RequestStringInput([]); // input must be a string, not array
27
+
} catch (InputException $e) {
28
+
echo $e->getMessage(); // "$string must be a string, "array" given."
29
+
}
30
+
31
+
// If input is invalid JSON
32
+
$input = new RequestStringInput('This is invalid JSON'); // input must be valid JSON
The `Art4\JsonApiClient\Exception\ValidationException` will be thrown if the response from the JSON API server doesn't follow the JSON API specification.
`$document` will be a [Document](objects-document.md) object which provided all contents.
21
21
22
-
> **Note:** If `$jsonapiString` contains not valid JSON or JSON API a [InputException](exception-introduction.md) or [ValidationException](exception-introduction.md#exceptionvalidationexception) will be thrown.
22
+
> **Note:** If `$jsonapiString` contains not valid JSON a [InputException](exception-introduction.md#inputexception) will be thrown.
23
+
> **Note:** If `$jsonapiString` contains not valid JSON API a [ValidationException](exception-introduction.md#validationexception) will be thrown.
23
24
>
24
25
> See more about Exceptions in the [Exception section](exception-introduction.md).
This returns a [Document](objects-document.md) object which provided all contents.
43
44
44
-
> **Note:** If `$jsonapiString` contains not valid JSON or JSON API a [InputException](exception-introduction.md) or [ValidationException](exception-introduction.md#exceptionvalidationexception) will be thrown.
45
+
> **Note:** If `$jsonapiString` contains not valid JSON a [InputException](exception-introduction.md#inputexception) will be thrown.
46
+
> **Note:** If `$jsonapiString` contains not valid JSON API a [ValidationException](exception-introduction.md#validationexception) will be thrown.
45
47
>
46
48
> See more about Exceptions in the [Exception section](exception-introduction.md).
This returns a [Document](objects-document.md) object which provided all contents.
26
26
27
-
> **Note:** If `$jsonapiString` contains not valid JSON or JSON API a [ValidationException](exception-introduction.md#exceptionvalidationexception) will be thrown.
27
+
> **Note:** If `$jsonapiString` contains not valid JSON a [InputException](exception-introduction.md#inputexception) will be thrown.
28
+
> **Note:** If `$jsonapiString` contains not valid JSON API a [ValidationException](exception-introduction.md#validationexception) will be thrown.
28
29
29
30
### Parse a JSON API string for creating a new resource
This returns a [Document](objects-document.md) object which provided all contents.
48
49
49
-
> **Note:** If `$jsonapiString` contains not valid JSON or JSON API a [ValidationException](exception-introduction.md#exceptionvalidationexception) will be thrown.
50
+
> **Note:** If `$jsonapiString` contains not valid JSON a [InputException](exception-introduction.md#inputexception) will be thrown.
51
+
> **Note:** If `$jsonapiString` contains not valid JSON API a [ValidationException](exception-introduction.md#validationexception) will be thrown.
Copy file name to clipboardExpand all lines: docs/objects-document.md
+5-1Lines changed: 5 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,12 +5,16 @@
5
5
6
6
The `Document` object represents the [Top Level](http://jsonapi.org/format/#document-top-level) of a JSON API response. You can create it using [Helper\Parser](helper-parser.md).
7
7
8
+
This object implements the [Accessable interface](objects-introduction.md#value-access).
> **Note:** Using `get()` on a non-existing value will throw an [AccessException](exception-introduction.md#exceptionaccessexception). Use `has()` or `getKeys()` to check if a value exists.
96
+
> **Note:** Using `get()` on a non-existing value will throw an [AccessException](exception-introduction.md#accessexception). Use `has()` or `getKeys()` to check if a value exists.
0 commit comments