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

Condition::parse()   D

Complexity

Conditions 27
Paths 24

Size

Total Lines 119
Code Lines 56

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 54
CRAP Score 27

Importance

Changes 0
Metric Value
cc 27
eloc 56
c 0
b 0
f 0
nc 24
nop 3
dl 0
loc 119
ccs 54
cts 54
cp 1
crap 27
rs 4.1666

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
final class Condition implements Component
12
{
13
    /**
14
     * Identifiers recognized.
15
     *
16
     * @var array<int, mixed>
17
     */
18
    public $identifiers = [];
19
20
    /**
21
     * Whether this component is an operator.
22
     *
23
     * @var bool
24
     */
25
    public $isOperator = false;
26
27
    /**
28
     * The condition.
29
     *
30
     * @var string
31
     */
32
    public $expr;
33
34
    /** @param string $expr the condition or the operator */
35 204
    public function __construct(string|null $expr = null)
36
    {
37 204
        $this->expr = trim((string) $expr);
38
    }
39
40 62
    public function build(): string
41
    {
42 62
        return $this->expr;
43
    }
44
45 62
    public function __toString(): string
46
    {
47 62
        return $this->build();
48
    }
49
}
50