Completed
Pull Request — master (#1051)
by Karel
07:07
created

FantaPaginatorAdapter::getFacets()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
namespace FOS\ElasticaBundle\Paginator;
4
5
use Pagerfanta\Adapter\AdapterInterface;
6
7
class FantaPaginatorAdapter implements AdapterInterface
8
{
9
    private $adapter;
10
11
    /**
12
     * @param \FOS\ElasticaBundle\Paginator\PaginatorAdapterInterface $adapter
13
     */
14 1
    public function __construct(PaginatorAdapterInterface $adapter)
15
    {
16 1
        $this->adapter = $adapter;
17 1
    }
18
19
    /**
20
     * Returns the number of results.
21
     *
22
     * @return integer The number of results.
23
     */
24
    public function getNbResults()
25
    {
26
        return $this->adapter->getTotalHits();
27
    }
28
29
    /**
30
     * Returns Facets.
31
     *
32
     * @return mixed
33
     */
34
    public function getFacets()
35
    {
36
        return $this->adapter->getFacets();
37
    }
38
39
    /**
40
     * Returns Aggregations.
41
     *
42
     * @return mixed
43
     *
44
     * @api
45
     */
46
    public function getAggregations()
47
    {
48
        return $this->adapter->getAggregations();
49
    }
50
51
    /**
52
     * Returns a slice of the results.
53
     *
54
     * @param integer $offset The offset.
55
     * @param integer $length The length.
56
     *
57
     * @return array|\Traversable The slice.
58
     */
59
    public function getSlice($offset, $length)
60
    {
61
        return $this->adapter->getResults($offset, $length)->toArray();
62
    }
63
}
64