Skip to content

Commit

Permalink
Remove unused methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Tigrov committed Mar 30, 2024
1 parent eb42831 commit 128dca4
Showing 1 changed file with 1 addition and 52 deletions.
53 changes: 1 addition & 52 deletions src/SqlParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,64 +48,13 @@ public function getNextPlaceholder(int|null &$position = null): string|null
return null;
}

/**
* Parses and returns identifier. Equals to `[_a-zA-Z][$\w]+` in regular expressions.
*
* @return string Parsed identifier.
*/
protected function parseIdentifier(): string
{
return match ($this->sql[$this->position]) {
'_',
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u',
'v', 'w', 'x', 'y', 'z',
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U',
'V', 'W', 'X', 'Y', 'Z' => $this->sql[$this->position++] . $this->parseWordWithDollar(),
default => '',
};
}

/**
* Parses and returns identifier without dollar sign. Equals to `[_a-zA-Z]\w+` in regular expressions.
*
* @return string Parsed identifier.
*/
private function parseIdentifierWithoutDollar(): string
{
return parent::parseIdentifier();
}

/**
* Parses and returns word symbols include dollar sign. Equals to `[$\w]+` in regular expressions.
*
* @return string Parsed word symbols.
*/
private function parseWordWithDollar(): string
{
$word = '';
$continue = true;

while ($continue && $this->position < $this->length) {
match ($this->sql[$this->position]) {
'$', '_', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u',
'v', 'w', 'x', 'y', 'z',
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U',
'V', 'W', 'X', 'Y', 'Z' => $word .= $this->sql[$this->position++],
default => $continue = false,
};
}

return $word;
}

/**
* Skips dollar-quoted string.
*/
private function skipQuotedWithDollar(): void
{
$pos = $this->position;
$identifier = $this->parseIdentifierWithoutDollar();
$identifier = $this->parseIdentifier();

if ($this->sql[$this->position] !== '$') {
$this->position = $pos;
Expand Down

0 comments on commit 128dca4

Please sign in to comment.