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