SortClauseHandler   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 32
c 0
b 0
f 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
accept() 0 1 ?
handle() 0 1 ?
A getDirection() 0 4 2
1
<?php
2
3
namespace Kaliop\EzFindSearchEngineBundle\Core\Persistence\eZFind\Content\Search\Common\Gateway;
4
5
use eZ\Publish\API\Repository\Values\Content\Query;
6
use eZ\Publish\API\Repository\Values\Content\Query\SortClause;
7
8
abstract class SortClauseHandler implements Handler
9
{
10
    /**
11
     * Check if this sort clause handler accepts to handle the given sort clause.
12
     *
13
     * @param \eZ\Publish\API\Repository\Values\Content\Query\SortClause $sortClause
14
     *
15
     * @return bool
16
     */
17
    abstract public function accept(SortClause $sortClause);
18
19
    /**
20
     * Map field value to a proper SOLR representation
21
     *
22
     * @param SortClause $sortClause
23
     *
24
     * @return array
25
     */
26
    abstract public function handle(SortClause $sortClause);
27
28
    /**
29
     * Get Solr sort direction from sort clause.
30
     *
31
     * @param SortClause $sortClause
32
     *
33
     * @return string
34
     */
35
    protected function getDirection(SortClause $sortClause)
36
    {
37
        return $sortClause->direction === Query::SORT_DESC ? 'desc' : 'asc';
38
    }
39
}
40