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

TransformedPaginatorAdapter   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 66.67%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getResults() 0 4 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