Searcher::find()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Radowoj\Searcher;
4
5
use Radowoj\Searcher\SearchProvider\ISearchProvider;
6
use Radowoj\Searcher\SearchResult\ICollection;
7
8
class Searcher implements ISearcher
9
{
10
11
    protected $provider = null;
12
13
    protected $query = '';
14
15
    protected $limit = 100;
16
17
    protected $offset = 0;
18
19
20 6
    public function __construct(ISearchProvider $provider)
21
    {
22 6
        $this->provider = $provider;
23 6
    }
24
25
26 3
    public function query(string $query) : ISearcher
27
    {
28 3
        $this->query = $query;
29 3
        return $this;
30
    }
31
32
33 3
    public function limit(int $limit) : ISearcher
34
    {
35 3
        $this->limit = $limit;
36 3
        return $this;
37
    }
38
39
40 3
    public function offset(int $offset) : ISearcher
41
    {
42 3
        $this->offset = $offset;
43 3
        return $this;
44
    }
45
46
47 2
    public function find() : ICollection
48
    {
49 2
        return $this->provider->search($this->query, $this->limit, $this->offset);
50
    }
51
52
}
53