@@ -98,13 +98,17 @@ public function __construct(
98
98
SchemaContainerInterface $ container ,
99
99
$ data
100
100
) {
101
+ \assert ($ position ->getLevel () >= ParserInterface::ROOT_LEVEL );
102
+
101
103
$ schema = $ container ->getSchema ($ data );
102
- $ this
103
- ->setPosition ($ position )
104
- ->setFactory ($ factory )
105
- ->setSchemaContainer ($ container )
106
- ->setSchema ($ schema )
107
- ->setData ($ data );
104
+
105
+ $ this ->position = $ position ;
106
+ $ this ->factory = $ factory ;
107
+ $ this ->schemaContainer = $ container ;
108
+ $ this ->schema = $ schema ;
109
+ $ this ->data = $ data ;
110
+ $ this ->index = $ schema ->getId ($ data );
111
+ $ this ->type = $ schema ->getType ();
108
112
}
109
113
110
114
/**
@@ -136,23 +140,23 @@ public function getType(): string
136
140
*/
137
141
public function hasIdentifierMeta (): bool
138
142
{
139
- return $ this ->getSchema () ->hasIdentifierMeta ($ this ->getData () );
143
+ return $ this ->schema ->hasIdentifierMeta ($ this ->data );
140
144
}
141
145
142
146
/**
143
147
* @inheritdoc
144
148
*/
145
149
public function getIdentifierMeta ()
146
150
{
147
- return $ this ->getSchema () ->getIdentifierMeta ($ this ->getData () );
151
+ return $ this ->schema ->getIdentifierMeta ($ this ->data );
148
152
}
149
153
150
154
/**
151
155
* @inheritdoc
152
156
*/
153
157
public function getAttributes (): iterable
154
158
{
155
- return $ this ->getSchema () ->getAttributes ($ this ->getData () );
159
+ return $ this ->schema ->getAttributes ($ this ->data );
156
160
}
157
161
158
162
/**
@@ -168,24 +172,24 @@ public function getRelationships(): iterable
168
172
169
173
$ this ->relationshipsCache = [];
170
174
171
- $ currentPath = $ this ->getPosition () ->getPath ();
172
- $ nextLevel = $ this ->getPosition () ->getLevel () + 1 ;
175
+ $ currentPath = $ this ->position ->getPath ();
176
+ $ nextLevel = $ this ->position ->getLevel () + 1 ;
173
177
$ nextPathPrefix = empty ($ currentPath ) === true ? '' : $ currentPath . PositionInterface::PATH_SEPARATOR ;
174
- foreach ($ this ->getSchema () ->getRelationships ($ this ->getData () ) as $ name => $ description ) {
178
+ foreach ($ this ->schema ->getRelationships ($ this ->data ) as $ name => $ description ) {
175
179
\assert ($ this ->assertRelationshipNameAndDescription ($ name , $ description ) === true );
176
180
177
181
[$ hasData , $ relationshipData , $ nextPosition ] = $ this ->parseRelationshipData (
178
- $ this ->getFactory () ,
179
- $ this ->getSchemaContainer () ,
180
- $ this ->getType () ,
182
+ $ this ->factory ,
183
+ $ this ->schemaContainer ,
184
+ $ this ->type ,
181
185
$ name ,
182
186
$ description ,
183
187
$ nextLevel ,
184
188
$ nextPathPrefix
185
189
);
186
190
187
191
[$ hasLinks , $ links ] =
188
- $ this ->parseRelationshipLinks ($ this ->getSchema () , $ this ->getData () , $ name , $ description );
192
+ $ this ->parseRelationshipLinks ($ this ->schema , $ this ->data , $ name , $ description );
189
193
190
194
$ hasMeta = \array_key_exists (SchemaInterface::RELATIONSHIP_META , $ description );
191
195
$ meta = $ hasMeta === true ? $ description [SchemaInterface::RELATIONSHIP_META ] : null ;
@@ -196,7 +200,7 @@ public function getRelationships(): iterable
196
200
'` MUST contain at least one of the following: links, data or meta. '
197
201
);
198
202
199
- $ relationship = $ this ->getFactory () ->createRelationship (
203
+ $ relationship = $ this ->factory ->createRelationship (
200
204
$ nextPosition ,
201
205
$ hasData ,
202
206
$ relationshipData ,
@@ -237,109 +241,15 @@ public function getLinks(): iterable
237
241
*/
238
242
public function hasResourceMeta (): bool
239
243
{
240
- return $ this ->getSchema () ->hasResourceMeta ($ this ->getData () );
244
+ return $ this ->schema ->hasResourceMeta ($ this ->data );
241
245
}
242
246
243
247
/**
244
248
* @inheritdoc
245
249
*/
246
250
public function getResourceMeta ()
247
251
{
248
- return $ this ->getSchema ()->getResourceMeta ($ this ->getData ());
249
- }
250
-
251
- /**
252
- * @inheritdoc
253
- */
254
- protected function setPosition (PositionInterface $ position ): self
255
- {
256
- \assert ($ position ->getLevel () >= ParserInterface::ROOT_LEVEL );
257
-
258
- $ this ->position = $ position ;
259
-
260
- return $ this ;
261
- }
262
-
263
- /**
264
- * @return FactoryInterface
265
- */
266
- protected function getFactory (): FactoryInterface
267
- {
268
- return $ this ->factory ;
269
- }
270
-
271
- /**
272
- * @param FactoryInterface $factory
273
- *
274
- * @return self
275
- */
276
- protected function setFactory (FactoryInterface $ factory ): self
277
- {
278
- $ this ->factory = $ factory ;
279
-
280
- return $ this ;
281
- }
282
-
283
- /**
284
- * @return SchemaContainerInterface
285
- */
286
- protected function getSchemaContainer (): SchemaContainerInterface
287
- {
288
- return $ this ->schemaContainer ;
289
- }
290
-
291
- /**
292
- * @param SchemaContainerInterface $container
293
- *
294
- * @return self
295
- */
296
- protected function setSchemaContainer (SchemaContainerInterface $ container ): self
297
- {
298
- $ this ->schemaContainer = $ container ;
299
-
300
- return $ this ;
301
- }
302
-
303
- /**
304
- * @return SchemaInterface
305
- */
306
- protected function getSchema (): SchemaInterface
307
- {
308
- return $ this ->schema ;
309
- }
310
-
311
- /**
312
- * @param SchemaInterface $schema
313
- *
314
- * @return self
315
- */
316
- protected function setSchema (SchemaInterface $ schema ): self
317
- {
318
- $ this ->schema = $ schema ;
319
-
320
- return $ this ;
321
- }
322
-
323
- /**
324
- * @return mixed
325
- */
326
- protected function getData ()
327
- {
328
- return $ this ->data ;
329
- }
330
-
331
- /**
332
- * @param mixed $data
333
- *
334
- * @return self
335
- */
336
- protected function setData ($ data ): self
337
- {
338
- $ this ->data = $ data ;
339
- $ this ->index = $ this ->getSchema ()->getId ($ data );
340
- $ this ->type = $ this ->getSchema ()->getType ();
341
-
342
- return $ this ;
252
+ return $ this ->schema ->getResourceMeta ($ this ->data );
343
253
}
344
254
345
255
/**
@@ -349,7 +259,7 @@ private function cacheLinks(): void
349
259
{
350
260
if ($ this ->links === null ) {
351
261
$ this ->links = [];
352
- foreach ($ this ->getSchema () ->getLinks ($ this ->getData () ) as $ name => $ link ) {
262
+ foreach ($ this ->schema ->getLinks ($ this ->data ) as $ name => $ link ) {
353
263
\assert (\is_string ($ name ) === true && empty ($ name ) === false );
354
264
\assert ($ link instanceof LinkInterface);
355
265
$ this ->links [$ name ] = $ link ;
0 commit comments