Passed
Push — master ( 6c3f09...c54108 )
by William
03:43
created

Component   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 54
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0
wmc 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PhpMyAdmin\SqlParser;
6
7
use Stringable;
8
9
/**
10
 * Defines a component that is later extended to parse specialized components or keywords.
11
 *
12
 * There is a small difference between *Component and *Keyword classes: usually, *Component parsers can be reused in
13
 * multiple situations and *Keyword parsers count on the *Component classes to do their job.
14
 *
15
 * A component (of a statement) is a part of a statement that is common to multiple query types.
16
 */
17
interface Component extends Stringable
18
{
19
    /**
20
     * Parses the tokens contained in the given list in the context of the given parser.
21
     *
22
     * @param Parser               $parser  the parser that serves as context
23
     * @param TokensList           $list    the list of tokens that are being parsed
24
     * @param array<string, mixed> $options parameters for parsing
25
     *
26
     * @return mixed
27
     */
28
    public static function parse(Parser $parser, TokensList $list, array $options = []);
29
30
    /**
31
     * Builds the string representation of a component of this type.
32
     *
33
     * In other words, this function represents the inverse function of {@see Component::parse()}.
34
     *
35
     * @param mixed                $component the component to be built
36
     * @param array<string, mixed> $options   parameters for building
37
     */
38
    public static function build($component, array $options = []): string;
39
}
40