| Total Complexity | 10 |
| Total Lines | 33 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 16 | abstract class BaseVariadicFunction extends BaseFunction |
||
| 17 | { |
||
| 18 | protected string $commonNodeMapping = 'StringPrimary'; |
||
| 19 | |||
| 20 | public function feedParserWithNodes(Parser $parser): void |
||
| 21 | { |
||
| 22 | $lexer = $parser->getLexer(); |
||
| 23 | |||
| 24 | $this->nodes[] = $parser->{$this->commonNodeMapping}(); |
||
| 25 | if (!$lexer->lookahead?->type) { |
||
| 26 | throw new \RuntimeException('The parser\'s "lookahead" property is not populated with a type'); |
||
| 27 | } |
||
| 28 | |||
| 29 | $aheadType = $lexer->lookahead->type; |
||
| 30 | $ormV2 = !class_exists(TokenType::class); |
||
| 31 | |||
| 32 | while (($ormV2 ? Lexer::T_CLOSE_PARENTHESIS : TokenType::T_CLOSE_PARENTHESIS) !== $aheadType) { |
||
|
|
|||
| 33 | if (($ormV2 ? Lexer::T_COMMA : TokenType::T_COMMA) === $aheadType) { |
||
| 34 | $parser->match($ormV2 ? Lexer::T_COMMA : TokenType::T_COMMA); |
||
| 35 | $this->nodes[] = $parser->{$this->commonNodeMapping}(); |
||
| 36 | } |
||
| 37 | $aheadType = $lexer->lookahead->type; |
||
| 38 | } |
||
| 39 | } |
||
| 40 | |||
| 41 | public function getSql(SqlWalker $sqlWalker): string |
||
| 49 | } |
||
| 50 | } |
||
| 51 |