Completed
Pull Request — master (#93)
by Krzysztof
06:57 queued 02:31
created

Cell   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 1
Metric Value
wmc 6
c 3
b 0
f 1
lcom 2
cbo 0
dl 0
loc 72
ccs 15
cts 15
cp 1
rs 10

6 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 hasName() 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 11
    public function __construct(
37
        SearcherInterface $searcher,
38
        TransformerInterface $transformer,
39
        $name = null
40
    ) {
41 11
        $this->searcher = $searcher;
42 11
        $this->transformer = $transformer;
43 11
        $this->name = $name;
44 11
    }
45
46
    /**
47
     * @return \KGzocha\Searcher\SearcherInterface
48
     */
49 5
    public function getSearcher()
50
    {
51 5
        return $this->searcher;
52
    }
53
54
    /**
55
     * @return TransformerInterface
56
     */
57 5
    public function getTransformer()
58
    {
59 5
        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 4
    public function hasName()
74
    {
75 4
        return null !== $this->name;
76
    }
77
78
    /**
79
     * @return bool
80
     */
81 6
    public function hasTransformer()
82
    {
83 6
        return !$this->transformer instanceof EndTransformer;
84
    }
85
}
86