1 | <?php declare(strict_types = 1); |
||
8 | abstract class PrettyJsonSerializable implements \JsonSerializable |
||
9 | { |
||
10 | const DEFAULT_CONTEXT = 'https://gbv.github.io/jskos/context.json'; |
||
11 | |||
12 | /** |
||
13 | * Returns data which should be serialized to JSON. |
||
14 | * |
||
15 | * Delegates to jsonLDSerialize which can be called with a JSON-LD context URL. |
||
16 | */ |
||
17 | public function jsonSerialize() |
||
21 | |||
22 | /** |
||
23 | * Returns data which should be serialized to JSON. |
||
24 | * |
||
25 | * Include all non-null members and the JSON-LD context (`@context`). |
||
26 | * Keys are sorted by Unicode codepoint for stable output. |
||
27 | * |
||
28 | * @param string $context optional JSON-LD context URL. Use empty string to omit. |
||
29 | * @param bool $types include default type URIs. |
||
30 | */ |
||
31 | public function jsonLDSerialize(string $context = self::DEFAULT_CONTEXT, bool $types = null) |
||
69 | |||
70 | /** |
||
71 | * Serialize to JSON in string context. |
||
72 | */ |
||
73 | public function __toString() |
||
77 | |||
78 | /** |
||
79 | * Serialize to pretty-printed JSON. |
||
80 | */ |
||
81 | public function json() |
||
85 | } |
||
86 |