SortClauseConverter   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 37
Duplicated Lines 35.14 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A canHandle() 0 11 3
A handle() 13 13 3

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
namespace Kaliop\EzFindSearchEngineBundle\Core\Persistence\eZFind\Content\Search\Common\Gateway;
4
5
use eZ\Publish\API\Repository\Values\Content\Query\SortClause;
6
use Kaliop\EzFindSearchEngineBundle\Core\Base\Exceptions\NotImplementedException;
7
8
class SortClauseConverter extends Converter
9
{
10
    /**
11
     * @param SortClause $sortClause
12
     * @return bool
13
     */
14
    public function canHandle(SortClause $sortClause)
15
    {
16
        /** @var SortClauseHandler $handler */
17
        foreach ($this->handlers as $handler) {
18
            if ($handler->accept($sortClause)) {
19
                return true;
20
            }
21
        }
22
23
        return false;
24
    }
25
26
    /**
27
     * @param SortClause $sortClause
28
     * @return array
29
     * @throws NotImplementedException
30
     */
31 View Code Duplication
    public function handle(SortClause $sortClause)
0 ignored issues
show
Duplication introduced by
This method 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...
32
    {
33
        /** @var SortClauseHandler $handler */
34
        foreach ($this->handlers as $handler) {
35
            if ($handler->accept($sortClause)) {
36
                return $handler->handle($sortClause);
37
            }
38
        }
39
40
        throw new NotImplementedException(
41
            'No handler available for: ' . get_class($sortClause) . ' with direction ' . $sortClause->direction
42
        );
43
    }
44
}
45