File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change 99 */
1010namespace WikibaseSolutions \CypherDSL \Patterns ;
1111
12+ use WikibaseSolutions \CypherDSL \Expressions \Label ;
1213use WikibaseSolutions \CypherDSL \Expressions \Literals \Map ;
1314use WikibaseSolutions \CypherDSL \Traits \ErrorTrait ;
1415use WikibaseSolutions \CypherDSL \Traits \EscapeTrait ;
@@ -81,6 +82,16 @@ public function getLabels(): array
8182 return $ this ->labels ;
8283 }
8384
85+ /**
86+ * Returns a label with the variable in this node.
87+ *
88+ * @param string ...$labels The labels to attach to the variable in this node
89+ */
90+ public function labeled (string ...$ labels ): Label
91+ {
92+ return new Label ($ this ->getVariable (), ...$ labels );
93+ }
94+
8495 /**
8596 * @inheritDoc
8697 */
Original file line number Diff line number Diff line change 1111
1212use PHPUnit \Framework \TestCase ;
1313use TypeError ;
14+ use WikibaseSolutions \CypherDSL \Expressions \Label ;
1415use WikibaseSolutions \CypherDSL \Expressions \Literals \Float_ ;
1516use WikibaseSolutions \CypherDSL \Expressions \Literals \Integer ;
1617use WikibaseSolutions \CypherDSL \Expressions \Literals \List_ ;
@@ -234,6 +235,22 @@ public function testRelationshipUni(): void
234235 $ this ->assertSame ("(:City)-[:LIVES_IN]-(:City {city: 'Amsterdam'}) " , $ relationship ->toQuery ());
235236 }
236237
238+ public function testLabeledSingleLabel (): void
239+ {
240+ $ node = new Node ();
241+ $ labeled = $ node ->labeled ('German ' );
242+
243+ $ this ->assertEquals (new Label ($ node ->getVariable (), 'German ' ), $ labeled );
244+ }
245+
246+ public function testLabeledMultipleLabels (): void
247+ {
248+ $ node = new Node ();
249+ $ labeled = $ node ->labeled ('German ' , 'Swedish ' );
250+
251+ $ this ->assertEquals (new Label ($ node ->getVariable (), 'German ' , 'Swedish ' ), $ labeled );
252+ }
253+
237254 public function provideOnlyLabelData (): array
238255 {
239256 return [
You can’t perform that action at this time.
0 commit comments