Passed
Push — master ( 6b91b6...1f7653 )
by William
07:14
created

NotImplementedStatement   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Test Coverage

Coverage 50%

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 37
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 parse() 0 8 3
A build() 0 11 2
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
12
/**
13
 * Not implemented (yet) statements.
14
 *
15
 * The `after` function makes the parser jump straight to the first delimiter.
16
 */
17
class NotImplementedStatement extends Statement
18
{
19
    /**
20
     * The part of the statement that can't be parsed.
21
     *
22
     * @var Token[]
23
     */
24
    public $unknown = [];
25
26
    /**
27
     * @return string
28
     */
29
    public function build()
30
    {
31
        // Building the parsed part of the query (if any).
32
        $query = parent::build() . ' ';
33
34
        // Rebuilding the unknown part from tokens.
35
        foreach ($this->unknown as $token) {
36
            $query .= $token->token;
37
        }
38
39
        return $query;
40
    }
41
42
    /**
43
     * @param Parser     $parser the instance that requests parsing
44
     * @param TokensList $list   the list of tokens to be parsed
45
     */
46 4
    public function parse(Parser $parser, TokensList $list)
47
    {
48 4
        for (; $list->idx < $list->count; ++$list->idx) {
49 4
            if ($list->tokens[$list->idx]->type === Token::TYPE_DELIMITER) {
50 4
                break;
51
            }
52
53 4
            $this->unknown[] = $list->tokens[$list->idx];
54
        }
55 1
    }
56
}
57