Passed
Pull Request — master (#483)
by
unknown
03:01
created

UnionKeyword::__toString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PhpMyAdmin\SqlParser\Components;
6
7
use PhpMyAdmin\SqlParser\Component;
8
use PhpMyAdmin\SqlParser\Parser;
9
use PhpMyAdmin\SqlParser\TokensList;
10
use PhpMyAdmin\SqlParser\Translator;
11
use RuntimeException;
12
13
use function implode;
14
15
/**
16
 * `UNION` keyword builder.
17
 */
18
final class UnionKeyword implements Component
19
{
20
    /**
21
     * Parses the tokens contained in the given list in the context of the given parser.
22
     *
23
     * @param Parser               $parser  the parser that serves as context
24
     * @param TokensList           $list    the list of tokens that are being parsed
25
     * @param array<string, mixed> $options parameters for parsing
26
     *
27
     * @return mixed
28
     *
29
     * @throws RuntimeException not implemented yet.
30
     */
31
    public static function parse(Parser $parser, TokensList $list, array $options = [])
32
    {
33
        throw new RuntimeException(Translator::gettext('Not implemented yet.'));
34
    }
35
36
    /**
37
     * @param UnionKeyword $component
38
     */
39
    public static function build($component): string
40
    {
41
        throw new RuntimeException(Translator::gettext('Not implemented yet.'));
42
    }
43
44
    /**
45
     * @param UnionKeyword[][] $component the component to be built
46
     */
47 8
    public static function buildAll(array $component): string
48
    {
49 8
        $tmp = [];
50 8
        foreach ($component as $componentPart) {
51 8
            $tmp[] = $componentPart[0] . ' ' . $componentPart[1];
52
        }
53
54 8
        return implode(' ', $tmp);
55
    }
56
57
    public function __toString(): string
58
    {
59
        return static::build($this);
60
    }
61
}
62