Completed
Push — master ( 31c1f9...0bd8b0 )
by Karel
10s
created

TransformedPaginatorAdapter::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 4
crap 1
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
class TransformedPaginatorAdapter extends RawPaginatorAdapter
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 array                               $options
20
     * @param ElasticaToModelTransformerInterface $transformer the transformer for fetching the results
21
     */
22 1
    public function __construct(SearchableInterface $searchable, Query $query, array $options = array(), ElasticaToModelTransformerInterface $transformer)
23
    {
24 1
        parent::__construct($searchable, $query, $options);
25
26 1
        $this->transformer = $transformer;
27 1
    }
28
29
    /**
30
     * {@inheritDoc}
31
     */
32
    public function getResults($offset, $length)
33
    {
34
        return new TransformedPartialResults($this->getElasticaResults($offset, $length), $this->transformer);
35
    }
36
}
37