NotImplementedStatement   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 50%

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 34
ccs 5
cts 10
cp 0.5
rs 10
c 0
b 0
f 0
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A build() 0 11 2
A parse() 0 8 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PhpMyAdmin\SqlParser\Statements;
6
7
use PhpMyAdmin\SqlParser\Parser;
8
use PhpMyAdmin\SqlParser\Statement;
9
use PhpMyAdmin\SqlParser\Token;
10
use PhpMyAdmin\SqlParser\TokensList;
11
use PhpMyAdmin\SqlParser\TokenType;
12
13
/**
14
 * Not implemented (yet) statements.
15
 *
16
 * The `after` function makes the parser jump straight to the first delimiter.
17
 */
18
class NotImplementedStatement extends Statement
19
{
20
    /**
21
     * The part of the statement that can't be parsed.
22
     *
23
     * @var Token[]
24
     */
25
    public array $unknown = [];
26
27
    public function build(): string
28
    {
29
        // Building the parsed part of the query (if any).
30
        $query = parent::build() . ' ';
31
32
        // Rebuilding the unknown part from tokens.
33
        foreach ($this->unknown as $token) {
34
            $query .= $token->token;
35
        }
36
37
        return $query;
38
    }
39
40
    /**
41
     * @param Parser     $parser the instance that requests parsing
42
     * @param TokensList $list   the list of tokens to be parsed
43
     */
44 2
    public function parse(Parser $parser, TokensList $list): void
45
    {
46 2
        for (; $list->idx < $list->count; ++$list->idx) {
47 2
            if ($list->tokens[$list->idx]->type === TokenType::Delimiter) {
48 2
                break;
49
            }
50
51 2
            $this->unknown[] = $list->tokens[$list->idx];
52
        }
53
    }
54
}
55