1 | <?php declare(strict_types=1); |
||
24 | class JsonAPI { |
||
25 | |||
26 | /** |
||
27 | * The full data array |
||
28 | * |
||
29 | * Basic structure is generally like so: |
||
30 | * @example [ |
||
31 | * 'id' => '12016665', |
||
32 | * 'type' => 'libraryEntries', |
||
33 | * 'links' => [ |
||
34 | * 'self' => 'https://kitsu.io/api/edge/library-entries/13016665' |
||
35 | * ], |
||
36 | * 'attributes' => [ |
||
37 | * |
||
38 | * ] |
||
39 | * ] |
||
40 | * |
||
41 | * @var array |
||
42 | */ |
||
43 | protected $data = []; |
||
44 | |||
45 | public static function inlineRawIncludes(array &$data, string $key): array |
||
54 | |||
55 | /** |
||
56 | * Take organized includes and inline them, where applicable |
||
57 | * |
||
58 | * @param array $included |
||
59 | * @param string $key The key of the include to inline the other included values into |
||
60 | * @return array |
||
61 | */ |
||
62 | public static function inlineIncludedRelationships(array $included, string $key): array |
||
85 | |||
86 | /** |
||
87 | * Reorganizes 'included' data to be keyed by |
||
88 | * type => [ |
||
89 | * id => data/attributes, |
||
90 | * ] |
||
91 | * |
||
92 | * @param array $includes |
||
93 | * @return array |
||
94 | */ |
||
95 | public static function organizeIncludes(array $includes): array |
||
114 | |||
115 | /** |
||
116 | * Reorganize relationship mappings to make them simpler to use |
||
117 | * |
||
118 | * Remove verbose structure, and just map: |
||
119 | * type => [ idArray ] |
||
120 | * |
||
121 | * @param array $relationships |
||
122 | * @return array |
||
123 | */ |
||
124 | public static function organizeRelationships(array $relationships): array |
||
145 | } |