1 | <?php declare(strict_types=1); |
||
34 | class IdentifierAndResource implements ResourceInterface |
||
35 | { |
||
36 | use ParseRelationshipDataTrait, ParseRelationshipLinksTrait; |
||
37 | |||
38 | /** @var string */ |
||
39 | public const MSG_NO_SCHEMA_FOUND = 'No Schema found for resource `%s` at path `%s`.'; |
||
40 | |||
41 | /** @var string */ |
||
42 | public const MSG_INVALID_OPERATION = 'Invalid operation.'; |
||
43 | |||
44 | /** |
||
45 | * @var PositionInterface |
||
46 | */ |
||
47 | private $position; |
||
48 | |||
49 | /** |
||
50 | * @var FactoryInterface |
||
51 | */ |
||
52 | private $factory; |
||
53 | |||
54 | /** |
||
55 | * @var SchemaContainerInterface |
||
56 | */ |
||
57 | private $schemaContainer; |
||
58 | |||
59 | /** |
||
60 | * @var SchemaInterface |
||
61 | */ |
||
62 | private $schema; |
||
63 | |||
64 | /** |
||
65 | * @var mixed |
||
66 | */ |
||
67 | private $data; |
||
68 | |||
69 | /** |
||
70 | * @var string |
||
71 | */ |
||
72 | private $index; |
||
73 | |||
74 | /** |
||
75 | * @var string |
||
76 | */ |
||
77 | private $type; |
||
78 | |||
79 | /** |
||
80 | * @var null|array |
||
81 | */ |
||
82 | private $links = null; |
||
83 | |||
84 | /** |
||
85 | * @var null|array |
||
86 | */ |
||
87 | private $relationshipsCache = null; |
||
88 | |||
89 | /** |
||
90 | * @param PositionInterface $position |
||
91 | * @param FactoryInterface $factory |
||
92 | * @param SchemaContainerInterface $container |
||
93 | * @param mixed $data |
||
94 | */ |
||
95 | 60 | public function __construct( |
|
109 | |||
110 | /** |
||
111 | * @inheritdoc |
||
112 | */ |
||
113 | 60 | public function getPosition(): PositionInterface |
|
117 | |||
118 | /** |
||
119 | * @inheritdoc |
||
120 | */ |
||
121 | 60 | public function getId(): ?string |
|
125 | |||
126 | /** |
||
127 | * @inheritdoc |
||
128 | */ |
||
129 | 60 | public function getType(): string |
|
133 | |||
134 | /** |
||
135 | * @inheritdoc |
||
136 | */ |
||
137 | 31 | public function hasIdentifierMeta(): bool |
|
141 | |||
142 | /** |
||
143 | * @inheritdoc |
||
144 | */ |
||
145 | 2 | public function getIdentifierMeta() |
|
149 | |||
150 | /** |
||
151 | * @inheritdoc |
||
152 | */ |
||
153 | 57 | public function getAttributes(): iterable |
|
157 | |||
158 | /** |
||
159 | * @inheritdoc |
||
160 | */ |
||
161 | 60 | public function getRelationships(): iterable |
|
213 | |||
214 | /** |
||
215 | * @inheritdoc |
||
216 | */ |
||
217 | 57 | public function hasLinks(): bool |
|
223 | |||
224 | /** |
||
225 | * @inheritdoc |
||
226 | */ |
||
227 | 56 | public function getLinks(): iterable |
|
233 | |||
234 | /** |
||
235 | * @inheritdoc |
||
236 | */ |
||
237 | 57 | public function hasResourceMeta(): bool |
|
241 | |||
242 | /** |
||
243 | * @inheritdoc |
||
244 | */ |
||
245 | 1 | public function getResourceMeta() |
|
249 | |||
250 | /** |
||
251 | * @inheritdoc |
||
252 | */ |
||
253 | 60 | protected function setPosition(PositionInterface $position): self |
|
261 | |||
262 | /** |
||
263 | * @return FactoryInterface |
||
264 | */ |
||
265 | protected function getFactory(): FactoryInterface |
||
269 | |||
270 | /** |
||
271 | * @param FactoryInterface $factory |
||
272 | * |
||
273 | * @return self |
||
274 | */ |
||
275 | 60 | protected function setFactory(FactoryInterface $factory): self |
|
281 | |||
282 | /** |
||
283 | * @return SchemaContainerInterface |
||
284 | */ |
||
285 | protected function getSchemaContainer(): SchemaContainerInterface |
||
289 | |||
290 | /** |
||
291 | * @param SchemaContainerInterface $container |
||
292 | * |
||
293 | * @return self |
||
294 | */ |
||
295 | 60 | protected function setSchemaContainer(SchemaContainerInterface $container): self |
|
301 | |||
302 | /** |
||
303 | * @return SchemaInterface |
||
304 | */ |
||
305 | 60 | protected function getSchema(): SchemaInterface |
|
309 | |||
310 | /** |
||
311 | * @param SchemaInterface $schema |
||
312 | * |
||
313 | * @return self |
||
314 | */ |
||
315 | 60 | protected function setSchema(SchemaInterface $schema): self |
|
321 | |||
322 | /** |
||
323 | * @return mixed |
||
324 | */ |
||
325 | 60 | protected function getData() |
|
329 | |||
330 | /** |
||
331 | * @param mixed $data |
||
332 | * |
||
333 | * @return self |
||
334 | */ |
||
335 | 60 | protected function setData($data): self |
|
343 | |||
344 | /** |
||
345 | * Read and parse links from schema. |
||
346 | */ |
||
347 | 57 | private function cacheLinks(): void |
|
358 | |||
359 | /** |
||
360 | * @param string $name |
||
361 | * @param array $description |
||
362 | * |
||
363 | * @return bool |
||
364 | */ |
||
365 | 45 | private function assertRelationshipNameAndDescription(string $name, array $description): bool |
|
378 | } |
||
379 |
This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.