Completed
Push — master ( c36253...8f6ddc )
by Krzysztof
7s
created

Cell::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 9
ccs 5
cts 5
cp 1
rs 9.6666
cc 1
eloc 7
nc 1
nop 3
crap 1
1
<?php
2
3
namespace KGzocha\Searcher\Chain;
4
5
use KGzocha\Searcher\SearcherInterface;
6
7
/**
8
 * It represents single cell in the chain. It holds sub-searcher and it's transformer, which will
9
 * transform results from it's sub-searcher to CriteriaCollection that can be used in next sub-search.
10
 * Name of the cell will be used as the key of end result collection to allow finding all the results.
11
 * 
12
 * @author Krzysztof Gzocha <[email protected]>
13
 */
14
class Cell implements CellInterface
15
{
16
    /**
17
     * @var SearcherInterface
18
     */
19
    private $searcher;
20
21
    /**
22
     * @var TransformerInterface
23
     */
24
    private $transformer;
25
26
    /**
27
     * @var string|null
28
     */
29
    private $name;
30
31
    /**
32
     * @param SearcherInterface    $searcher
33
     * @param TransformerInterface $transformer
34
     * @param string               $name
35
     */
36 7
    public function __construct(
37
        SearcherInterface $searcher,
38
        TransformerInterface $transformer,
39
        $name = null
40
    ) {
41 7
        $this->searcher = $searcher;
42 7
        $this->transformer = $transformer;
43 7
        $this->name = $name;
44 7
    }
45
46
    /**
47
     * @return \KGzocha\Searcher\SearcherInterface
48
     */
49 4
    public function getSearcher()
50
    {
51 4
        return $this->searcher;
52
    }
53
54
    /**
55
     * @return TransformerInterface
56
     */
57 4
    public function getTransformer()
58
    {
59 4
        return $this->transformer;
60
    }
61
62
    /**
63
     * @return null|string
64
     */
65 4
    public function getName()
66
    {
67 4
        return $this->name;
68
    }
69
70
    /**
71
     * @return bool
72
     */
73 5
    public function hasTransformer()
74
    {
75 5
        return !$this->transformer instanceof EndTransformer;
76
    }
77
}
78