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

FantaPaginatorAdapter   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 27.27%

Importance

Changes 0
Metric Value
wmc 5
c 0
b 0
f 0
lcom 1
cbo 2
dl 0
loc 57
ccs 3
cts 11
cp 0.2727
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getNbResults() 0 4 1
A getFacets() 0 4 1
A getAggregations() 0 4 1
A getSlice() 0 4 1
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