Completed
Pull Request — master (#1117)
by Karel
06:17
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

Importance

Changes 0
Metric Value
c 0
b 0
f 0
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 Aggregations.
31
     *
32
     * @return mixed
33
     *
34
     * @api
35
     */
36
    public function getAggregations()
37
    {
38
        return $this->adapter->getAggregations();
39
    }
40
41
    /**
42
     * Returns a slice of the results.
43
     *
44
     * @param integer $offset The offset.
45
     * @param integer $length The length.
46
     *
47
     * @return array|\Traversable The slice.
48
     */
49
    public function getSlice($offset, $length)
50
    {
51
        return $this->adapter->getResults($offset, $length)->toArray();
52
    }
53
}
54