Skip to content

Commit f5b28b6

Browse files
committed
Simplifying the next character logic
1 parent ae813ad commit f5b28b6

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

src/PHPCR/Util/QOM/Sql2Scanner.php

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ protected function scan($sql2)
175175
}
176176
$stringSize = $this->parseBrackets($sql2, $index);
177177
$bracketContent = substr($sql2, $index + 1, $stringSize - 2);
178-
$tokens[] = '[' . trim($bracketContent, '"') . ']';
178+
$tokens[] = '['.trim($bracketContent, '"').']';
179179

180180
// We need to subtract one here because the for loop will automatically increment the index
181181
$index += $stringSize - 1;
@@ -187,7 +187,7 @@ protected function scan($sql2)
187187
if (!$isEscaped && in_array($character, ['"', "'"], true)) {
188188
// Checking if the previous or next value is a ' to handle the weird SQL strings
189189
// This will not check if the amount of quotes is even
190-
$nextCharacter = $this->getCharacterAtIndex($sql2, $index + 1);
190+
$nextCharacter = $splitString[$index + 1] ?? '';
191191
if ($character === "'" && $nextCharacter === "'") {
192192
$isEscaped = true;
193193
$escapedQuotesCount++;
@@ -226,15 +226,6 @@ protected function scan($sql2)
226226
return $tokens;
227227
}
228228

229-
private function getCharacterAtIndex($string, $index)
230-
{
231-
if ($index < strlen($string)) {
232-
return $string[$index];
233-
}
234-
235-
return '';
236-
}
237-
238229
private function parseBrackets(string $query, int $index): int
239230
{
240231
$endPosition = strpos($query, ']', $index) + 1;

0 commit comments

Comments
 (0)