ScrollingSearchingContext::getResults()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
declare(strict_types=1);
3
4
namespace KGzocha\Searcher\Context\Elastica;
5
6
use Elastica\Query;
7
use Elastica\Scroll;
8
use Elastica\Search;
9
10
/**
11
 * @author Krzysztof Gzocha <[email protected]>
12
 */
13
class ScrollingSearchingContext extends QuerySearchingContext
14
{
15
    /**
16
     * @var string
17
     */
18
    private $expiryTime;
19
20
    /**
21
     * @inheritDoc
22
     */
23 1
    public function __construct(Search $search, Query $query = null, string $expiryTime = '1m')
24
    {
25 1
        parent::__construct($search, $query);
26 1
        $this->expiryTime = $expiryTime;
27 1
    }
28
29
    /**
30
     * @return Scroll|\Iterator
31
     */
32 1
    public function getResults(): \Iterator
33
    {
34
        $this
35 1
            ->getSearch()
36 1
            ->setQuery($this->getQueryBuilder());
37
38 1
        return $this->getSearch()->scroll($this->expiryTime);
39
    }
40
}
41