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

Component::build()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 5
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
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