Completed
Pull Request — master (#1616)
by
unknown
06:41
created

TransformedScrollPaginatorAdapter::getResults()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 4
Ratio 100 %

Importance

Changes 0
Metric Value
dl 4
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
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 TransformedScrollPaginatorAdapter extends RawScrollPaginatorAdapter
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 array                               $options
29
     * @param ElasticaToModelTransformerInterface $transformer the transformer for fetching the results
30
     */
31
    public function __construct(SearchableInterface $searchable, Query $query, array $options, ElasticaToModelTransformerInterface $transformer)
32
    {
33
        parent::__construct($searchable, $query, $options);
34
35
        $this->transformer = $transformer;
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41
    public function getResults($offset, $length)
42
    {
43
        return new TransformedPartialResults($this->getElasticaResults($offset, $length), $this->transformer);
44
    }
45
}
46