ArrayParser   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 45.71 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 16
loc 35
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A parse() 16 16 3

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
namespace Xiag\Rql\Parser\ValueParser;
3
4
use Xiag\Rql\Parser\Token;
5
use Xiag\Rql\Parser\TokenStream;
6
use Xiag\Rql\Parser\SubParserInterface;
7
8
class ArrayParser implements SubParserInterface
9
{
10
    /**
11
     * @var SubParserInterface
12
     */
13
    protected $itemParser;
14
15
    /**
16
     * @param SubParserInterface $itemParser
17
     */
18 64
    public function __construct(SubParserInterface $itemParser)
19
    {
20 64
        $this->itemParser = $itemParser;
21 64
    }
22
23
    /**
24
     * @inheritdoc
25
     */
26 12 View Code Duplication
    public function parse(TokenStream $tokenStream)
0 ignored issues
show
Duplication introduced by
This method 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...
27
    {
28 12
        $tokenStream->expect(Token::T_OPEN_PARENTHESIS);
29
30 11
        $values = [];
31
        do {
32 11
            $values[] = $this->itemParser->parse($tokenStream);
33 11
            if (!$tokenStream->nextIf(Token::T_COMMA)) {
34 9
                break;
35
            }
36 11
        } while (true);
37
38 9
        $tokenStream->expect(Token::T_CLOSE_PARENTHESIS);
39
40 9
        return $values;
41
    }
42
}
43