LocationPriority::accept()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Kaliop\EzFindSearchEngineBundle\Core\Persistence\eZFind\Content\Search\Common\Gateway\CriterionHandler;
4
5
use eZ\Publish\API\Repository\Values\Content\Query\Criterion;
6
use Kaliop\EzFindSearchEngineBundle\Core\Persistence\eZFind\Content\Search\Common\Gateway\CriteriaConverter;
7
use Kaliop\EzFindSearchEngineBundle\Core\Persistence\eZFind\Content\Search\Common\Gateway\CriterionHandler;
8
9
class LocationPriority extends CriterionHandler
10
{
11
    public function accept( Criterion $criterion )
12
    {
13
        return $criterion instanceof Criterion\LocationPriority;
14
    }
15
16
    public function handle( CriteriaConverter $converter, Criterion $criterion )
17
    {
18
        switch ( $criterion->operator )
19
        {
20 View Code Duplication
            case Criterion\Operator::BETWEEN:
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
21
                return 'priority:[' . $this->escapeValue($criterion->value[0]) . ' TO ' . $this->escapeValue($criterion->value[1]) . ']';
22
23
            case Criterion\Operator::GT:
24
                return 'priority:{' . $this->escapeValue(reset( $criterion->value )) . ' TO *]';
25
26
            case Criterion\Operator::GTE:
27
                return 'priority:[' . $this->escapeValue(reset( $criterion->value )) . ' TO *]';
28
29
            case Criterion\Operator::LT:
30
                return 'priority:[* TO ' . $this->escapeValue(reset( $criterion->value )) . '}';
31
32
            case Criterion\Operator::LTE:
33
                return 'priority:[* TO ' . $this->escapeValue(reset( $criterion->value )) . ']';
34
35
        }
36
    }
37
}
38