phpmyadmin /
sql-parser
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace PhpMyAdmin\SqlParser\Components; |
||
| 6 | |||
| 7 | use PhpMyAdmin\SqlParser\Component; |
||
| 8 | |||
| 9 | use function trim; |
||
| 10 | |||
| 11 | /** |
||
| 12 | * `GROUP BY` keyword parser. |
||
| 13 | */ |
||
| 14 | final class GroupKeyword implements Component |
||
| 15 | { |
||
| 16 | /** @var 'ASC'|'DESC'|null */ |
||
|
0 ignored issues
–
show
Documentation
Bug
introduced
by
Loading history...
|
|||
| 17 | public string|null $type = null; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * The expression that is used for grouping. |
||
| 21 | */ |
||
| 22 | public Expression|null $expr = null; |
||
| 23 | |||
| 24 | /** @param Expression|null $expr the expression that we are sorting by */ |
||
| 25 | 38 | public function __construct(Expression|null $expr = null) |
|
| 26 | { |
||
| 27 | 38 | $this->expr = $expr; |
|
| 28 | } |
||
| 29 | |||
| 30 | 36 | public function build(): string |
|
| 31 | { |
||
| 32 | 36 | return trim((string) $this->expr); |
|
| 33 | } |
||
| 34 | |||
| 35 | 30 | public function __toString(): string |
|
| 36 | { |
||
| 37 | 30 | return $this->build(); |
|
| 38 | } |
||
| 39 | } |
||
| 40 |