Completed
Pull Request — master (#1494)
by
unknown
04:09
created

HybridPaginatorAdapter   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getResults() 0 6 1
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
class HybridPaginatorAdapter extends RawPaginatorAdapter
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
        $results = $this->getElasticaResults($offset, $length);
43 1
        $hybridPartialResults = new HybridPartialResults($results, $this->transformer);
44 1
        return $hybridPartialResults;
45
    }
46
}
47