Completed
Pull Request — master (#1134)
by Istvan
14:27
created

HybridPaginatorAdapter   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 66.67%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 1
cbo 2
dl 24
loc 24
ccs 4
cts 6
cp 0.6667
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 6 6 1
A getResults() 4 4 1

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 FOS\ElasticaBundle\Paginator;
4
5
use FOS\ElasticaBundle\Transformer\ElasticaToModelTransformerInterface;
6
use Elastica\SearchableInterface;
7
use Elastica\Query;
8
9
/**
10
 * Allows pagination of \Elastica\Query
11
 */
12 View Code Duplication
class HybridPaginatorAdapter extends RawPaginatorAdapter
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...
13
{
14
    private $transformer;
15
16
    /**
17
     * @param SearchableInterface $searchable the object to search in
18
     * @param Query $query the query to search
19
     * @param ElasticaToModelTransformerInterface $transformer the transformer for fetching the results
20
     */
21 1
    public function __construct(SearchableInterface $searchable, Query $query, ElasticaToModelTransformerInterface $transformer)
22
    {
23 1
        parent::__construct($searchable, $query);
24
25 1
        $this->transformer = $transformer;
26 1
    }
27
28
    /**
29
     * {@inheritDoc}
30
     */
31
    public function getResults($offset, $length)
32
    {
33
        return new HybridPartialResults($this->getElasticaResults($offset, $length), $this->transformer);
34
    }
35
}
36