ScrollingSearchingContext   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 28
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getResults() 0 8 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