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 |
|
214 | |||
215 | /** |
||
216 | * @inheritdoc |
||
217 | */ |
||
218 | 57 | public function hasLinks(): bool |
|
224 | |||
225 | /** |
||
226 | * @inheritdoc |
||
227 | */ |
||
228 | 56 | public function getLinks(): iterable |
|
234 | |||
235 | /** |
||
236 | * @inheritdoc |
||
237 | */ |
||
238 | 57 | public function hasResourceMeta(): bool |
|
242 | |||
243 | /** |
||
244 | * @inheritdoc |
||
245 | */ |
||
246 | 1 | public function getResourceMeta() |
|
250 | |||
251 | /** |
||
252 | * @inheritdoc |
||
253 | */ |
||
254 | 60 | protected function setPosition(PositionInterface $position): self |
|
262 | |||
263 | /** |
||
264 | * @return FactoryInterface |
||
265 | */ |
||
266 | 45 | protected function getFactory(): FactoryInterface |
|
270 | |||
271 | /** |
||
272 | * @param FactoryInterface $factory |
||
273 | * |
||
274 | * @return self |
||
275 | */ |
||
276 | 60 | protected function setFactory(FactoryInterface $factory): self |
|
282 | |||
283 | /** |
||
284 | * @return SchemaContainerInterface |
||
285 | */ |
||
286 | 45 | protected function getSchemaContainer(): SchemaContainerInterface |
|
290 | |||
291 | /** |
||
292 | * @param SchemaContainerInterface $container |
||
293 | * |
||
294 | * @return self |
||
295 | */ |
||
296 | 60 | protected function setSchemaContainer(SchemaContainerInterface $container): self |
|
302 | |||
303 | /** |
||
304 | * @return SchemaInterface |
||
305 | */ |
||
306 | 60 | protected function getSchema(): SchemaInterface |
|
310 | |||
311 | /** |
||
312 | * @param SchemaInterface $schema |
||
313 | * |
||
314 | * @return self |
||
315 | */ |
||
316 | 60 | protected function setSchema(SchemaInterface $schema): self |
|
322 | |||
323 | /** |
||
324 | * @return mixed |
||
325 | */ |
||
326 | 60 | protected function getData() |
|
330 | |||
331 | /** |
||
332 | * @param mixed $data |
||
333 | * |
||
334 | * @return self |
||
335 | */ |
||
336 | 60 | protected function setData($data): self |
|
344 | |||
345 | /** |
||
346 | * Read and parse links from schema. |
||
347 | */ |
||
348 | 57 | private function cacheLinks(): void |
|
359 | |||
360 | /** |
||
361 | * @param string $name |
||
362 | * @param array $description |
||
363 | * |
||
364 | * @return bool |
||
365 | */ |
||
366 | 45 | private function assertRelationshipNameAndDescription(string $name, array $description): bool |
|
379 | } |
||
380 |
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.