Skip to content

Commit ba70946

Browse files
Wout Gevaerttransistive
authored andcommitted
Change order of methods in JoltHttpOGMTranslator
First the public methods, and then group the private methods by functionality
1 parent 21532f0 commit ba70946

File tree

1 file changed

+48
-48
lines changed

1 file changed

+48
-48
lines changed

src/Formatter/Specialised/JoltHttpOGMTranslator.php

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,23 @@ public function __construct()
7373
];
7474
}
7575

76+
public function decorateRequest(RequestInterface $request): RequestInterface
77+
{
78+
/** @psalm-suppress ImpureMethodCall */
79+
return $request->withHeader(
80+
'Accept',
81+
'application/vnd.neo4j.jolt+json-seq;strict=true;charset=UTF-8'
82+
);
83+
}
84+
85+
/**
86+
* @return array{resultDataContents?: list<'GRAPH'|'ROW'|'REST'>, includeStats?:bool}
87+
*/
88+
public function statementConfigOverride(): array
89+
{
90+
return [];
91+
}
92+
7693
/**
7794
* @return CypherList<CypherList<CypherMap<OGMTypes>>>
7895
*/
@@ -126,37 +143,6 @@ private function translateJoltType(?stdClass $value)
126143
return $this->rawToTypes[$key]($input);
127144
}
128145

129-
/**
130-
* @return OGMTypes
131-
*
132-
* @psalm-suppress ImpureMethodCall
133-
* @psalm-suppress PossiblyFalseReference
134-
*/
135-
private function translateDateTime(string $datetime)
136-
{
137-
if (preg_match('/^[\-−]?\d+-\d{2}-\d{2}$/u', $datetime)) {
138-
$date = DateTimeImmutable::createFromFormat('Y-m-d', $datetime);
139-
140-
return new Date((int) $date->diff(new DateTimeImmutable('@0'))->format('%a'));
141-
}
142-
143-
if (preg_match('/^(\d{2}):(\d{2}):(\d{2})((\.)(\d+))?$/', $datetime, $matches)) {
144-
$nanoseconds = $this->nanosecondsFromMatches($matches);
145-
146-
return new LocalTime($nanoseconds);
147-
}
148-
149-
if (preg_match('/^(\d{2}):(\d{2}):(\d{2})((\.)(\d+))?(?<zone>.+)$/', $datetime, $matches)) {
150-
$nanoseconds = $this->nanosecondsFromMatches($matches);
151-
152-
$offset = $this->offsetFromMatches($matches);
153-
154-
return new Time($nanoseconds, $offset);
155-
}
156-
157-
throw new UnexpectedValueException('Date/time values have not been implemented yet');
158-
}
159-
160146
/**
161147
* Assumes that 2D points are of the form "SRID=$srid;POINT($x $y)" and 3D points are of the form "SRID=$srid;POINT Z($x $y $z)".
162148
*
@@ -290,23 +276,6 @@ private function translatePath(array $value): Path
290276
return new Path(new CypherList($nodes), new CypherList($relations), new CypherList($ids));
291277
}
292278

293-
public function decorateRequest(RequestInterface $request): RequestInterface
294-
{
295-
/** @psalm-suppress ImpureMethodCall */
296-
return $request->withHeader(
297-
'Accept',
298-
'application/vnd.neo4j.jolt+json-seq;strict=true;charset=UTF-8'
299-
);
300-
}
301-
302-
/**
303-
* @return array{resultDataContents?: list<'GRAPH'|'ROW'|'REST'>, includeStats?:bool}
304-
*/
305-
public function statementConfigOverride(): array
306-
{
307-
return [];
308-
}
309-
310279
/**
311280
* @param array{0: int, 1: list<string>, 2: stdClass} $value
312281
*/
@@ -336,6 +305,37 @@ private function translateBinary(): Closure
336305
throw new UnexpectedValueException('Binary data has not been implemented');
337306
}
338307

308+
/**
309+
* @return OGMTypes
310+
*
311+
* @psalm-suppress ImpureMethodCall
312+
* @psalm-suppress PossiblyFalseReference
313+
*/
314+
private function translateDateTime(string $datetime)
315+
{
316+
if (preg_match('/^[\-−]?\d+-\d{2}-\d{2}$/u', $datetime)) {
317+
$date = DateTimeImmutable::createFromFormat('Y-m-d', $datetime);
318+
319+
return new Date((int) $date->diff(new DateTimeImmutable('@0'))->format('%a'));
320+
}
321+
322+
if (preg_match('/^(\d{2}):(\d{2}):(\d{2})((\.)(\d+))?$/', $datetime, $matches)) {
323+
$nanoseconds = $this->nanosecondsFromMatches($matches);
324+
325+
return new LocalTime($nanoseconds);
326+
}
327+
328+
if (preg_match('/^(\d{2}):(\d{2}):(\d{2})((\.)(\d+))?(?<zone>.+)$/', $datetime, $matches)) {
329+
$nanoseconds = $this->nanosecondsFromMatches($matches);
330+
331+
$offset = $this->offsetFromMatches($matches);
332+
333+
return new Time($nanoseconds, $offset);
334+
}
335+
336+
throw new UnexpectedValueException('Date/time values have not been implemented yet');
337+
}
338+
339339
private function nanosecondsFromMatches(array $matches): int
340340
{
341341
/** @var array{0: string, 1: string, 2: string, 3: string, 4?: array{0: string, 1: string}} $matches */

0 commit comments

Comments
 (0)