Skip to content

Commit bfbec4d

Browse files
Wout Gevaerttransistive
authored andcommitted
Add missing imports and minor fixes
1 parent c056c91 commit bfbec4d

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

src/Formatter/Specialised/JoltHttpOGMTranslator.php

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,15 @@
1414
use Laudis\Neo4j\Contracts\ConnectionInterface;
1515
use Laudis\Neo4j\Contracts\PointInterface;
1616
use Laudis\Neo4j\Formatter\OGMFormatter;
17+
use Laudis\Neo4j\Http\HttpHelper;
18+
use Laudis\Neo4j\Types\AbstractPropertyObject;
1719
use Laudis\Neo4j\Types\CypherList;
20+
use Laudis\Neo4j\Types\Cartesian3DPoint;
21+
use Laudis\Neo4j\Types\CartesianPoint;
22+
use Laudis\Neo4j\Types\WGS84Point;
23+
use Laudis\Neo4j\Types\WGS843DPoint;
24+
use Laudis\Neo4j\Types\Relation;
25+
use Laudis\Neo4j\Types\Node;
1826
use Laudis\Neo4j\Types\CypherMap;
1927
use Psr\Http\Message\RequestInterface;
2028
use Psr\Http\Message\ResponseInterface;
@@ -38,7 +46,7 @@ public function __construct()
3846
'Z' => static fn (string $value): int => (int) $value,
3947
'R' => static fn (string $value): float => (float) $value,
4048
'U' => static fn (string $value): string => $value,
41-
'T' => fn (string $value)/*TODO*/ => $this->translateDateTime($value),
49+
'T' => fn (string $value): AbstractPropertyObject => $this->translateDateTime($value),
4250
'@' => fn (string $value): PointInterface => $this->translatePoint($value),
4351
'#' => static function (string $value) {
4452
// TODO
@@ -82,6 +90,18 @@ public function formatHttpResult(
8290
return new CypherList($allResults);
8391
}
8492

93+
private function translateJoltType(?stdClass $value) {
94+
if (is_null($value)) {
95+
return null;
96+
}
97+
98+
[$key, $value] = HttpHelper::splitJoltSingleton($value);
99+
if (!isset($this->rawToTypes[$key])) {
100+
throw new UnexpectedValueException('Unexpected Jolt key: ' . $key);
101+
}
102+
return $this->rawToTypes[$key]($value);
103+
}
104+
85105
private function translateDateTime(string $datetime)
86106
{
87107
// TODO; They're in ISO format so shouldn't be too hard
@@ -142,7 +162,7 @@ private function getSRID(string $value): int
142162
private function getCoordinates(string $value): array
143163
{
144164
$matches = [];
145-
if (!preg_match('/^POINT ?(Z?) ?\(([0-9 ]+)\)$/', $value, $matches)) {
165+
if (!preg_match('/^POINT ?(Z?) ?\(([0-9\. ]+)\)$/', $value, $matches)) {
146166
throw new UnexpectedValueException('Unexpected point coordinates string: '.$value);
147167
}
148168
$coordinates = explode(' ', $matches[2]);

0 commit comments

Comments
 (0)