1 | <?php |
||
20 | class Transform |
||
21 | { |
||
22 | |||
23 | /** |
||
24 | * The character used to separate modifier parameters. |
||
25 | * |
||
26 | * @var string |
||
27 | */ |
||
28 | public $paramDelimiter = '|'; |
||
29 | |||
30 | /** |
||
31 | * Upper limit to how many levels of included data are allowed. |
||
32 | * |
||
33 | * @var int |
||
34 | */ |
||
35 | public $recursionLimit = 10; |
||
36 | |||
37 | /** |
||
38 | * Scope identifiers that resources can optionally include. |
||
39 | * |
||
40 | * @var array |
||
41 | */ |
||
42 | protected $includes = []; |
||
43 | |||
44 | /** |
||
45 | * Scope identifiers that resources must exclude. |
||
46 | * |
||
47 | * @var array |
||
48 | */ |
||
49 | protected $excludes = []; |
||
50 | |||
51 | /** |
||
52 | * Scope identifiers that resources must return. |
||
53 | * |
||
54 | * @var array |
||
55 | */ |
||
56 | protected $fields = []; |
||
57 | |||
58 | /** |
||
59 | * Array containing modifiers as keys and an array value of params. |
||
60 | * |
||
61 | * @var array |
||
62 | */ |
||
63 | protected $params = []; |
||
64 | |||
65 | /** |
||
66 | * @param array $config |
||
67 | */ |
||
68 | public function __construct(array $config = []) |
||
72 | |||
73 | /** |
||
74 | * @param string $include |
||
75 | * |
||
76 | * @return ParamBag |
||
77 | */ |
||
78 | public function getParams($include): ParamBag |
||
83 | |||
84 | /******************************************* |
||
85 | * INCLUDES |
||
86 | *******************************************/ |
||
87 | |||
88 | /** |
||
89 | * Get Requested Includes. |
||
90 | * |
||
91 | * @return array |
||
92 | */ |
||
93 | public function getIncludes(): array |
||
97 | |||
98 | /** |
||
99 | * Parse Include String. |
||
100 | * |
||
101 | * @param array|string $includes Array or csv string of resources to include |
||
102 | * |
||
103 | * @return $this |
||
104 | */ |
||
105 | public function setIncludes($includes) |
||
166 | |||
167 | /******************************************* |
||
168 | * EXCLUDES |
||
169 | *******************************************/ |
||
170 | |||
171 | /** |
||
172 | * Get Requested Excludes. |
||
173 | * |
||
174 | * @return array |
||
175 | */ |
||
176 | public function getExcludes(): array |
||
180 | |||
181 | /** |
||
182 | * Parse Exclude String. |
||
183 | * |
||
184 | * @param array|string $excludes Array or csv string of resources to exclude |
||
185 | * |
||
186 | * @return $this |
||
187 | */ |
||
188 | public function setExcludes($excludes) |
||
214 | |||
215 | /******************************************* |
||
216 | * FIELDS |
||
217 | *******************************************/ |
||
218 | |||
219 | /** |
||
220 | * Parse field parameter. |
||
221 | * |
||
222 | * @param array $fields Array of fields to include. It must be an array |
||
223 | * whose keys are resource types and values a string |
||
224 | * of the fields to return, separated by a comma |
||
225 | * |
||
226 | * @return $this |
||
227 | */ |
||
228 | public function setFields(array $fields) |
||
241 | |||
242 | /** |
||
243 | * Get requested fields. |
||
244 | * |
||
245 | * @return array |
||
246 | */ |
||
247 | public function getFields(): array |
||
251 | |||
252 | /** |
||
253 | * Get field params for the specified type. |
||
254 | * |
||
255 | * @param string $type |
||
256 | * |
||
257 | * @return ParamBag|null |
||
258 | */ |
||
259 | public function getField($type) |
||
265 | |||
266 | /** |
||
267 | * Auto-include Parents |
||
268 | * |
||
269 | * Look at the requested includes and automatically include the parents if they |
||
270 | * are not explicitly requested. E.g: [foo, bar.baz] becomes [foo, bar, bar.baz] |
||
271 | * |
||
272 | * @internal |
||
273 | * |
||
274 | * @return void |
||
275 | */ |
||
276 | protected function autoIncludeParents() |
||
296 | |||
297 | /** |
||
298 | * Trim to Acceptable Recursion Level |
||
299 | * |
||
300 | * @internal |
||
301 | * |
||
302 | * @param string $includeName |
||
303 | * |
||
304 | * @return string |
||
305 | */ |
||
306 | protected function trimToAcceptableRecursionLevel($includeName) |
||
310 | |||
311 | } |
||
312 |