These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
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
|
|||
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 | 3 | public function __construct(SearchableInterface $searchable, Query $query, ElasticaToModelTransformerInterface $transformer) |
|
31 | { |
||
32 | 3 | parent::__construct($searchable, $query); |
|
33 | |||
34 | 3 | $this->transformer = $transformer; |
|
35 | 3 | } |
|
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 |
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.