Completed
Push — master ( 6a0101...61ff1f )
by Karel
10:05 queued 08:15
created

HybridPaginatorAdapter   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

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
/*
4
 * This file is part of the FOSElasticaBundle package.
5
 *
6
 * (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace FOS\ElasticaBundle\Paginator;
13
14
use Elastica\Query;
15
use Elastica\SearchableInterface;
16
use FOS\ElasticaBundle\Transformer\ElasticaToModelTransformerInterface;
17
18
/**
19
 * Allows pagination of \Elastica\Query.
20
 */
21 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...
22
{
23
    private $transformer;
24
25
    /**
26
     * @param SearchableInterface                 $searchable  the object to search in
27
     * @param Query                               $query       the query to search
28
     * @param ElasticaToModelTransformerInterface $transformer the transformer for fetching the results
29
     */
30 2
    public function __construct(SearchableInterface $searchable, Query $query, ElasticaToModelTransformerInterface $transformer)
31
    {
32 2
        parent::__construct($searchable, $query);
33
34 2
        $this->transformer = $transformer;
35 2
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40 1
    public function getResults($offset, $length)
41
    {
42 1
        return new HybridPartialResults($this->getElasticaResults($offset, $length), $this->transformer);
43
    }
44
}
45