GroupKeyword   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
dl 0
loc 24
ccs 6
cts 6
cp 1
rs 10
c 1
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __toString() 0 3 1
A build() 0 3 1
A __construct() 0 3 1
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
The doc comment 'ASC'|'DESC'|null at position 0 could not be parsed: Unknown type name ''ASC'' at position 0 in 'ASC'|'DESC'|null.
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