Completed
Push — master ( 357c73...c8ba24 )
by Karel
37:25 queued 27:22
created

FantaPaginatorAdapter   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 33.33%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 47
ccs 3
cts 9
cp 0.3333
rs 10

4 Methods

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