AndNodeParser::getOperatorName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 4
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
namespace Xiag\Rql\Parser\NodeParser\Query\LogicalOperator;
3
4
use Xiag\Rql\Parser\Exception\SyntaxErrorException;
5
use Xiag\Rql\Parser\NodeParser\Query\AbstractLogicalOperatorNodeParser;
6
use Xiag\Rql\Parser\Node\Query\LogicalOperator\AndNode;
7
8 View Code Duplication
class AndNodeParser extends AbstractLogicalOperatorNodeParser
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...
9
{
10
    /**
11
     * @inheritdoc
12
     */
13 64
    protected function getOperatorName()
14
    {
15 64
        return 'and';
16
    }
17
18
    /**
19
     * @inheritdoc
20
     */
21 3
    protected function createNode(array $queries)
22
    {
23 3
        if (count($queries) < 2) {
24 1
            throw new SyntaxErrorException(
25 1
                sprintf(
26 1
                    '"%s" operator expects at least 2 parameters, %d given',
27 1
                    $this->getOperatorName(),
28 1
                    count($queries)
29 1
                )
30 1
            );
31
        }
32
33 2
        return new AndNode($queries);
34
    }
35
}
36