Code Duplication    Length = 28-28 lines in 3 locations

src/NodeParser/Query/LogicalOperator/AndNodeParser.php 1 location

@@ 8-35 (lines=28) @@
5
use Xiag\Rql\Parser\NodeParser\Query\AbstractLogicalOperatorNodeParser;
6
use Xiag\Rql\Parser\Node\Query\LogicalOperator\AndNode;
7
8
class AndNodeParser extends AbstractLogicalOperatorNodeParser
9
{
10
    /**
11
     * @inheritdoc
12
     */
13
    protected function getOperatorName()
14
    {
15
        return 'and';
16
    }
17
18
    /**
19
     * @inheritdoc
20
     */
21
    protected function createNode(array $queries)
22
    {
23
        if (count($queries) < 2) {
24
            throw new SyntaxErrorException(
25
                sprintf(
26
                    '"%s" operator expects at least 2 parameters, %d given',
27
                    $this->getOperatorName(),
28
                    count($queries)
29
                )
30
            );
31
        }
32
33
        return new AndNode($queries);
34
    }
35
}
36

src/NodeParser/Query/LogicalOperator/NotNodeParser.php 1 location

@@ 8-35 (lines=28) @@
5
use Xiag\Rql\Parser\NodeParser\Query\AbstractLogicalOperatorNodeParser;
6
use Xiag\Rql\Parser\Node\Query\LogicalOperator\NotNode;
7
8
class NotNodeParser extends AbstractLogicalOperatorNodeParser
9
{
10
    /**
11
     * @inheritdoc
12
     */
13
    protected function getOperatorName()
14
    {
15
        return 'not';
16
    }
17
18
    /**
19
     * @inheritdoc
20
     */
21
    protected function createNode(array $queries)
22
    {
23
        if (count($queries) !== 1) {
24
            throw new SyntaxErrorException(
25
                sprintf(
26
                    '"%s" operator expects 1 parameter, %d given',
27
                    $this->getOperatorName(),
28
                    count($queries)
29
                )
30
            );
31
        }
32
33
        return new NotNode($queries);
34
    }
35
}
36

src/NodeParser/Query/LogicalOperator/OrNodeParser.php 1 location

@@ 8-35 (lines=28) @@
5
use Xiag\Rql\Parser\NodeParser\Query\AbstractLogicalOperatorNodeParser;
6
use Xiag\Rql\Parser\Node\Query\LogicalOperator\OrNode;
7
8
class OrNodeParser extends AbstractLogicalOperatorNodeParser
9
{
10
    /**
11
     * @inheritdoc
12
     */
13
    protected function getOperatorName()
14
    {
15
        return 'or';
16
    }
17
18
    /**
19
     * @inheritdoc
20
     */
21
    protected function createNode(array $queries)
22
    {
23
        if (count($queries) < 2) {
24
            throw new SyntaxErrorException(
25
                sprintf(
26
                    '"%s" operator expects at least 2 parameters, %d given',
27
                    $this->getOperatorName(),
28
                    count($queries)
29
                )
30
            );
31
        }
32
33
        return new OrNode($queries);
34
    }
35
}
36