Completed
Push — master ( cfe8d7...fcc746 )
by André
19:36 queued 06:48
created

LogicalAnd   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 23
loc 23
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A accept() 4 4 1
A handle() 9 9 2

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
/**
4
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
5
 * @license For full copyright and license information view LICENSE file distributed with this source code.
6
 */
7
namespace eZ\Publish\Core\Persistence\Legacy\URL\Query\CriterionHandler;
8
9
use eZ\Publish\API\Repository\Values\URL\Query\Criterion;
10
use eZ\Publish\Core\Persistence\Legacy\URL\Query\CriteriaConverter;
11
use eZ\Publish\Core\Persistence\Legacy\URL\Query\CriterionHandler;
12
use eZ\Publish\Core\Persistence\Database\SelectQuery;
13
14 View Code Duplication
class LogicalAnd implements CriterionHandler
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...
15
{
16
    /**
17
     * {@inheritdoc}
18
     */
19
    public function accept(Criterion $criterion)
20
    {
21
        return $criterion instanceof Criterion\LogicalAnd;
22
    }
23
24
    /**
25
     * {@inheritdoc}
26
     */
27
    public function handle(CriteriaConverter $converter, SelectQuery $query, Criterion $criterion)
28
    {
29
        $subexpressions = [];
30
        foreach ($criterion->criteria as $subCriterion) {
0 ignored issues
show
Bug introduced by
The property criteria does not seem to exist in eZ\Publish\API\Repositor...ues\URL\Query\Criterion.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
31
            $subexpressions[] = $converter->convertCriteria($query, $subCriterion);
32
        }
33
34
        return $query->expr->lAnd($subexpressions);
35
    }
36
}
37