Skip to content

Commit 9aeb94a

Browse files
committed
added shorthand method property relationship
1 parent 7c06265 commit 9aeb94a

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

src/Formatter/Specialised/HttpOGMArrayTranslator.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@
1313

1414
namespace Laudis\Neo4j\Formatter\Specialised;
1515

16-
use Laudis\Neo4j\Types\Path;
17-
use Laudis\Neo4j\Types\UnboundRelationship;
1816
use function is_array;
1917
use Laudis\Neo4j\Contracts\PointInterface;
2018
use Laudis\Neo4j\Types\Cartesian3DPoint;
2119
use Laudis\Neo4j\Types\CartesianPoint;
2220
use Laudis\Neo4j\Types\CypherList;
2321
use Laudis\Neo4j\Types\CypherMap;
2422
use Laudis\Neo4j\Types\Node;
23+
use Laudis\Neo4j\Types\Path;
2524
use Laudis\Neo4j\Types\Relationship;
25+
use Laudis\Neo4j\Types\UnboundRelationship;
2626
use Laudis\Neo4j\Types\WGS843DPoint;
2727
use Laudis\Neo4j\Types\WGS84Point;
2828

@@ -153,7 +153,7 @@ private function path(array $meta, array $nodes, array $relationships, int $relI
153153
}
154154

155155
/**
156-
* @param list<NodeArray> $nodes
156+
* @param list<NodeArray> $nodes
157157
*/
158158
private function translateNode(array $nodes, int $id): Node
159159
{

src/Types/Relationship.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313

1414
namespace Laudis\Neo4j\Types;
1515

16+
use Laudis\Neo4j\Exception\PropertyDoesNotExistException;
17+
use function sprintf;
18+
1619
/**
1720
* A Relationship class representing a Relationship in cypher.
1821
*
@@ -106,4 +109,18 @@ public function toArray(): array
106109
'properties' => $this->getProperties(),
107110
];
108111
}
112+
113+
/**
114+
* Gets the property of the relationship by key.
115+
*
116+
* @return OGMTypes
117+
*/
118+
public function getProperty(string $key)
119+
{
120+
if (!$this->properties->hasKey($key)) {
121+
throw new PropertyDoesNotExistException(sprintf('Property "%s" does not exist on relationship', $key));
122+
}
123+
124+
return $this->properties->get($key);
125+
}
109126
}

0 commit comments

Comments
 (0)