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

SetOperation::parse()   C

Complexity

Conditions 15
Paths 8

Size

Total Lines 84
Code Lines 40

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 41
CRAP Score 15

Importance

Changes 0
Metric Value
cc 15
eloc 40
c 0
b 0
f 0
nc 8
nop 3
dl 0
loc 84
ccs 41
cts 41
cp 1
crap 15
rs 5.9166

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
final class SetOperation implements Component
10
{
11
    /**
12
     * The name of the column that is being updated.
13
     *
14
     * @var string
15
     */
16
    public $column;
17
18
    /**
19
     * The new value.
20
     *
21
     * @var string
22
     */
23
    public $value;
24
25
    /**
26
     * @param string $column Field's name..
27
     * @param string $value  new value
28
     */
29 120
    public function __construct(string $column = '', string $value = '')
30
    {
31 120
        $this->column = $column;
32 120
        $this->value = $value;
33
    }
34
35 36
    public function build(): string
36
    {
37 36
        return $this->column . ' = ' . $this->value;
38
    }
39
40 36
    public function __toString(): string
41
    {
42 36
        return $this->build();
43
    }
44
}
45