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

RawPartialResults::getFacets()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 0
cts 7
cp 0
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 4
nc 2
nop 0
crap 12
1
<?php
2
3
namespace FOS\ElasticaBundle\Paginator;
4
5
use Elastica\ResultSet;
6
use Elastica\Result;
7
8
/**
9
 * Raw partial results transforms to a simple array.
10
 */
11
class RawPartialResults implements PartialResultsInterface
12
{
13
    protected $resultSet;
14
15
    /**
16
     * @param ResultSet $resultSet
17
     */
18
    public function __construct(ResultSet $resultSet)
19
    {
20
        $this->resultSet = $resultSet;
21
    }
22
23
    /**
24
     * {@inheritDoc}
25
     */
26
    public function toArray()
27
    {
28
        return array_map(function (Result $result) {
29
            return $result->getSource();
30
        }, $this->resultSet->getResults());
31
    }
32
33
    /**
34
     * {@inheritDoc}
35
     */
36
    public function getTotalHits()
37
    {
38
        return $this->resultSet->getTotalHits();
39
    }
40
41
    /**
42
     * {@inheritDoc}
43
     */
44
    public function getAggregations()
45
    {
46
        if ($this->resultSet->hasAggregations()) {
47
            return $this->resultSet->getAggregations();
48
        }
49
50
        return;
51
    }
52
}
53