GroupKeyword::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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