28
28
use WikibaseSolutions \CypherDSL \Traits \EscapeTrait ;
29
29
use WikibaseSolutions \CypherDSL \Traits \RelationshipTrait ;
30
30
use WikibaseSolutions \CypherDSL \Types \StructuralTypes \RelationshipType ;
31
- use WikibaseSolutions \CypherDSL \Types \StructuralTypes \StructuralType ;
32
31
33
32
/**
34
33
* This class represents an arbitrary relationship between two nodes, a node and a
@@ -45,16 +44,6 @@ class Relationship implements RelationshipType
45
44
public const DIR_LEFT = ["<- " , "- " ];
46
45
public const DIR_UNI = ["- " , "- " ];
47
46
48
- /**
49
- * @var StructuralType The pattern left of the relationship
50
- */
51
- private StructuralType $ left ;
52
-
53
- /**
54
- * @var StructuralType The pattern right of the relationship
55
- */
56
- private StructuralType $ right ;
57
-
58
47
/**
59
48
* @var string[] The direction of the relationship
60
49
*/
@@ -83,19 +72,14 @@ class Relationship implements RelationshipType
83
72
/**
84
73
* Path constructor.
85
74
*
86
- * @param StructuralType $left The node left of the relationship
87
- * @param StructuralType $right The node right of the relationship
88
75
* @param array $direction The direction of the relationship, should be either:
89
76
* - Path::DIR_RIGHT (for a relation of
90
77
* (a)-->(b)) - Path::DIR_LEFT (for a relation
91
78
* of (a)<--(b)) - Path::DIR_UNI (for a
92
79
* relation of (a)--(b))
93
80
*/
94
- public function __construct (StructuralType $ left , StructuralType $ right , array $ direction )
81
+ public function __construct (array $ direction )
95
82
{
96
- $ this ->left = $ left ;
97
- $ this ->right = $ right ;
98
-
99
83
if ($ direction !== self ::DIR_RIGHT && $ direction !== self ::DIR_LEFT && $ direction !== self ::DIR_UNI ) {
100
84
throw new InvalidArgumentException ("The direction must be either 'DIR_LEFT', 'DIR_RIGHT' or 'RELATED_TO' " );
101
85
}
@@ -199,10 +183,7 @@ public function withType(string $type): self
199
183
*/
200
184
public function toQuery (): string
201
185
{
202
- $ a = $ this ->left ->toQuery ();
203
- $ b = $ this ->right ->toQuery ();
204
-
205
- return $ a . $ this ->toRelationshipQuery () . $ b ;
186
+ return $ this ->direction [0 ] . $ this ->conditionToString () . $ this ->direction [1 ];
206
187
}
207
188
208
189
/**
@@ -254,36 +235,6 @@ private function conditionToString(): string
254
235
return sprintf ("[%s] " , $ conditionInner );
255
236
}
256
237
257
- /**
258
- * Returns the left structure of the relationship.
259
- *
260
- * @return StructuralType
261
- */
262
- public function getLeft (): StructuralType
263
- {
264
- return $ this ->left ;
265
- }
266
-
267
- /**
268
- * Returns the right structure of the relationship.
269
- *
270
- * @return StructuralType
271
- */
272
- public function getRight (): StructuralType
273
- {
274
- return $ this ->right ;
275
- }
276
-
277
- /**
278
- * Returns the direction of the path.
279
- *
280
- * @return string[]
281
- */
282
- public function getDirection (): array
283
- {
284
- return $ this ->direction ;
285
- }
286
-
287
238
/**
288
239
* Returns the exact amount of hops configured.
289
240
*
@@ -328,14 +279,4 @@ public function property(string $property): Property
328
279
{
329
280
return new Property ($ this ->getName (), $ property );
330
281
}
331
-
332
- /**
333
- * Returns the relationship part of the pattern without the nodes.
334
- *
335
- * @return string
336
- */
337
- public function toRelationshipQuery (): string
338
- {
339
- return $ this ->direction [0 ] . $ this ->conditionToString () . $ this ->direction [1 ];
340
- }
341
282
}
0 commit comments