1 | <?php |
||
23 | class Scope |
||
24 | { |
||
25 | |||
26 | /** |
||
27 | * @var string |
||
28 | */ |
||
29 | protected $scopeIdentifier; |
||
30 | |||
31 | /** |
||
32 | * @var Factory |
||
33 | */ |
||
34 | protected $factory; |
||
35 | |||
36 | /** |
||
37 | * @var ResourceInterface |
||
38 | */ |
||
39 | protected $resource; |
||
40 | |||
41 | /** |
||
42 | * @var array |
||
43 | */ |
||
44 | protected $parentScopes = []; |
||
45 | |||
46 | /** |
||
47 | * Scope constructor. |
||
48 | * @param Factory $factory |
||
49 | * @param ResourceInterface $resource |
||
50 | * @param string|null $scopeIdentifier |
||
51 | * @param array $parentScopes |
||
52 | */ |
||
53 | public function __construct(Factory $factory, ResourceInterface $resource, string $scopeIdentifier = null, array $parentScopes = []) |
||
60 | |||
61 | /** |
||
62 | * @return ResourceInterface |
||
63 | */ |
||
64 | public function getResource(): ResourceInterface |
||
68 | |||
69 | /** |
||
70 | * Getter for manager. |
||
71 | * |
||
72 | * @return Factory |
||
73 | */ |
||
74 | public function getFactory(): Factory |
||
78 | |||
79 | /** |
||
80 | * @param $key |
||
81 | * @return ParamBag |
||
82 | */ |
||
83 | public function getParams(string $key = null): ParamBag |
||
89 | |||
90 | /** |
||
91 | * Get the current identifier. |
||
92 | * |
||
93 | * @return string|null |
||
94 | */ |
||
95 | public function getScopeIdentifier() |
||
99 | |||
100 | /** |
||
101 | * Get the unique identifier for this scope. |
||
102 | * |
||
103 | * @param string $appendIdentifier |
||
104 | * |
||
105 | * @return string |
||
106 | */ |
||
107 | public function getIdentifier(string $appendIdentifier = null): string |
||
120 | |||
121 | /** |
||
122 | * Getter for parentScopes. |
||
123 | * |
||
124 | * @return array |
||
125 | */ |
||
126 | public function getParentScopes(): array |
||
130 | |||
131 | /** |
||
132 | * Is Requested. |
||
133 | * |
||
134 | * Check if - in relation to the current scope - this specific segment is allowed. |
||
135 | * That means, if a.b.c is requested and the current scope is a.b, then c is allowed. If the current |
||
136 | * scope is a then c is not allowed, even if it is there and potentially transformable. |
||
137 | * |
||
138 | * @internal |
||
139 | * |
||
140 | * @param string $checkScopeSegment |
||
141 | * |
||
142 | * @return bool Returns the new number of elements in the array. |
||
143 | */ |
||
144 | public function isRequested($checkScopeSegment): bool |
||
151 | |||
152 | /** |
||
153 | * Is Excluded. |
||
154 | * |
||
155 | * Check if - in relation to the current scope - this specific segment should |
||
156 | * be excluded. That means, if a.b.c is excluded and the current scope is a.b, |
||
157 | * then c will not be allowed in the transformation whether it appears in |
||
158 | * the list of default or available, requested includes. |
||
159 | * |
||
160 | * @internal |
||
161 | * |
||
162 | * @param string $checkScopeSegment |
||
163 | * |
||
164 | * @return bool |
||
165 | */ |
||
166 | public function isExcluded($checkScopeSegment): bool |
||
173 | |||
174 | /** |
||
175 | * Convert the current data for this scope to an array. |
||
176 | * |
||
177 | * @return array|null |
||
178 | */ |
||
179 | public function transform() |
||
209 | |||
210 | /** |
||
211 | * Fire the main transformer. |
||
212 | * |
||
213 | * @internal |
||
214 | * |
||
215 | * @param TransformerInterface|callable $transformer |
||
216 | * @param mixed $data |
||
217 | * |
||
218 | * @return array |
||
219 | */ |
||
220 | protected function fireTransformer(callable $transformer, $data): array |
||
254 | |||
255 | /** |
||
256 | * @param callable $transformer |
||
257 | * @param string $key |
||
258 | * @return bool |
||
259 | */ |
||
260 | protected function includeValue(callable $transformer, string $key): bool |
||
276 | |||
277 | /** |
||
278 | * @param $val |
||
279 | * @param $data |
||
280 | * @param string|null $key |
||
281 | * @return array|string|null |
||
282 | */ |
||
283 | protected function parseValue($val, $data, string $key = null) |
||
302 | |||
303 | /** |
||
304 | * Check, if this is the root scope. |
||
305 | * |
||
306 | * @return bool |
||
307 | */ |
||
308 | protected function isRootScope(): bool |
||
312 | |||
313 | /** |
||
314 | * Filter the provided data with the requested filter fields for |
||
315 | * the scope resource |
||
316 | * |
||
317 | * @internal |
||
318 | * |
||
319 | * @param array $data |
||
320 | * |
||
321 | * @return array |
||
322 | */ |
||
323 | protected function filterFields(array $data): array |
||
340 | |||
341 | /** |
||
342 | * Return the requested filter fields for the scope resource |
||
343 | * |
||
344 | * @internal |
||
345 | * |
||
346 | * @return ParamBag|null |
||
347 | */ |
||
348 | protected function getFilterFields() |
||
354 | |||
355 | /** |
||
356 | * @param string $checkScopeSegment |
||
357 | * @return string |
||
358 | */ |
||
359 | private function _scopeString(string $checkScopeSegment): string |
||
372 | |||
373 | } |
||
374 |
This check looks at variables that have been passed in as parameters and are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.