@@ -98,13 +98,17 @@ public function __construct(
9898 SchemaContainerInterface $ container ,
9999 $ data
100100 ) {
101+ \assert ($ position ->getLevel () >= ParserInterface::ROOT_LEVEL );
102+
101103 $ 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 ();
108112 }
109113
110114 /**
@@ -136,23 +140,23 @@ public function getType(): string
136140 */
137141 public function hasIdentifierMeta (): bool
138142 {
139- return $ this ->getSchema () ->hasIdentifierMeta ($ this ->getData () );
143+ return $ this ->schema ->hasIdentifierMeta ($ this ->data );
140144 }
141145
142146 /**
143147 * @inheritdoc
144148 */
145149 public function getIdentifierMeta ()
146150 {
147- return $ this ->getSchema () ->getIdentifierMeta ($ this ->getData () );
151+ return $ this ->schema ->getIdentifierMeta ($ this ->data );
148152 }
149153
150154 /**
151155 * @inheritdoc
152156 */
153157 public function getAttributes (): iterable
154158 {
155- return $ this ->getSchema () ->getAttributes ($ this ->getData () );
159+ return $ this ->schema ->getAttributes ($ this ->data );
156160 }
157161
158162 /**
@@ -168,24 +172,24 @@ public function getRelationships(): iterable
168172
169173 $ this ->relationshipsCache = [];
170174
171- $ currentPath = $ this ->getPosition () ->getPath ();
172- $ nextLevel = $ this ->getPosition () ->getLevel () + 1 ;
175+ $ currentPath = $ this ->position ->getPath ();
176+ $ nextLevel = $ this ->position ->getLevel () + 1 ;
173177 $ 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 ) {
175179 \assert ($ this ->assertRelationshipNameAndDescription ($ name , $ description ) === true );
176180
177181 [$ hasData , $ relationshipData , $ nextPosition ] = $ this ->parseRelationshipData (
178- $ this ->getFactory () ,
179- $ this ->getSchemaContainer () ,
180- $ this ->getType () ,
182+ $ this ->factory ,
183+ $ this ->schemaContainer ,
184+ $ this ->type ,
181185 $ name ,
182186 $ description ,
183187 $ nextLevel ,
184188 $ nextPathPrefix
185189 );
186190
187191 [$ hasLinks , $ links ] =
188- $ this ->parseRelationshipLinks ($ this ->getSchema () , $ this ->getData () , $ name , $ description );
192+ $ this ->parseRelationshipLinks ($ this ->schema , $ this ->data , $ name , $ description );
189193
190194 $ hasMeta = \array_key_exists (SchemaInterface::RELATIONSHIP_META , $ description );
191195 $ meta = $ hasMeta === true ? $ description [SchemaInterface::RELATIONSHIP_META ] : null ;
@@ -196,7 +200,7 @@ public function getRelationships(): iterable
196200 '` MUST contain at least one of the following: links, data or meta. '
197201 );
198202
199- $ relationship = $ this ->getFactory () ->createRelationship (
203+ $ relationship = $ this ->factory ->createRelationship (
200204 $ nextPosition ,
201205 $ hasData ,
202206 $ relationshipData ,
@@ -237,109 +241,15 @@ public function getLinks(): iterable
237241 */
238242 public function hasResourceMeta (): bool
239243 {
240- return $ this ->getSchema () ->hasResourceMeta ($ this ->getData () );
244+ return $ this ->schema ->hasResourceMeta ($ this ->data );
241245 }
242246
243247 /**
244248 * @inheritdoc
245249 */
246250 public function getResourceMeta ()
247251 {
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 );
343253 }
344254
345255 /**
@@ -349,7 +259,7 @@ private function cacheLinks(): void
349259 {
350260 if ($ this ->links === null ) {
351261 $ this ->links = [];
352- foreach ($ this ->getSchema () ->getLinks ($ this ->getData () ) as $ name => $ link ) {
262+ foreach ($ this ->schema ->getLinks ($ this ->data ) as $ name => $ link ) {
353263 \assert (\is_string ($ name ) === true && empty ($ name ) === false );
354264 \assert ($ link instanceof LinkInterface);
355265 $ this ->links [$ name ] = $ link ;
0 commit comments