Passed
Push — master ( b16987...8b6d77 )
by Maurício
03:49 queued 13s
created

ArrayObj::parse()   D

Complexity

Conditions 23
Paths 20

Size

Total Lines 102
Code Lines 46

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 47
CRAP Score 23

Importance

Changes 0
Metric Value
cc 23
eloc 46
c 0
b 0
f 0
nc 20
nop 3
dl 0
loc 102
ccs 47
cts 47
cp 1
crap 23
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 implode;
10
11
/**
12
 * Parses an array.
13
 */
14
final class ArrayObj implements Component
15
{
16
    /**
17
     * The array that contains the unprocessed value of each token.
18
     *
19
     * @var string[]
20
     */
21
    public array $raw = [];
22
23
    /**
24
     * The array that contains the processed value of each token.
25
     *
26
     * @var string[]
27
     */
28
    public array $values = [];
29
30
    /**
31
     * @param string[] $raw    the unprocessed values
32
     * @param string[] $values the processed values
33
     */
34 264
    public function __construct(array $raw = [], array $values = [])
35
    {
36 264
        $this->raw = $raw;
37 264
        $this->values = $values;
38
    }
39
40 22
    public function build(): string
41
    {
42 22
        if ($this->raw !== []) {
43 20
            return '(' . implode(', ', $this->raw) . ')';
44
        }
45
46 2
        return '(' . implode(', ', $this->values) . ')';
47
    }
48
49 18
    public function __toString(): string
50
    {
51 18
        return $this->build();
52
    }
53
}
54