Passed
Push — master ( 42feb8...1cd426 )
by Dominik
02:11
created

StringNode   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 37
loc 37
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 8 8 1
A serializeEmpty() 4 4 1
A serialize() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
declare(strict_types=1);
4
5
namespace Saxulum\ElasticSearchQueryBuilder\Node;
6
7 View Code Duplication
final class StringNode extends AbstractNode
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
8
{
9
    /**
10
     * @var string|null
11
     */
12
    private $value;
13
14
    /**
15
     * @param string|null $value
16
     * @param bool $allowSerializeEmpty
17
     * @return StringNode
18
     */
19 4
    public static function create(string $value = null, bool $allowSerializeEmpty = false): StringNode
20
    {
21 4
        $node = new self;
22 4
        $node->value = $value;
23 4
        $node->allowSerializeEmpty = $allowSerializeEmpty;
24
25 4
        return $node;
26
    }
27
28
    /**
29
     * @return null
30
     */
31 1
    public function serializeEmpty()
32
    {
33 1
        return;
34
    }
35
36
    /**
37
     * @return string|null
38
     */
39 2
    public function serialize()
40
    {
41 2
        return $this->value;
42
    }
43
}
44