Completed
Push — master ( 578d3a...04a929 )
by Maurício
34s queued 14s
created

GroupKeyword::parse()   C

Complexity

Conditions 14
Paths 6

Size

Total Lines 64
Code Lines 28

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 27
CRAP Score 14

Importance

Changes 0
Metric Value
cc 14
eloc 28
c 0
b 0
f 0
nc 6
nop 3
dl 0
loc 64
ccs 27
cts 27
cp 1
crap 14
rs 6.2666

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

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
     * @var Expression
23
     */
24
    public $expr;
25
26
    /** @param Expression $expr the expression that we are sorting by */
27 38
    public function __construct(Expression|null $expr = null)
28
    {
29 38
        $this->expr = $expr;
30
    }
31
32 36
    public function build(): string
33
    {
34 36
        return trim((string) $this->expr);
35
    }
36
37 30
    public function __toString(): string
38
    {
39 30
        return $this->build();
40
    }
41
}
42