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

Cell   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 5
c 2
b 0
f 1
lcom 1
cbo 0
dl 0
loc 64
ccs 13
cts 13
cp 1
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
A getSearcher() 0 4 1
A getTransformer() 0 4 1
A getName() 0 4 1
A hasTransformer() 0 4 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