Total Complexity | 5 |
Total Lines | 33 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
10 | final class LocatorBuilder implements LocatorBuilderInterface |
||
11 | { |
||
12 | |||
13 | private $locator; |
||
14 | |||
15 | private $referenceFactory; |
||
16 | |||
17 | private $references = []; |
||
18 | |||
19 | 5 | public function __construct(ReferenceFactoryInterface $referenceFactory) |
|
20 | { |
||
21 | 5 | $this->referenceFactory = $referenceFactory; |
|
22 | 5 | } |
|
23 | |||
24 | 3 | public function addReference(string $text): void |
|
25 | { |
||
26 | 3 | if (isset($this->locator)) { |
|
27 | 1 | throw new Exception\LocatorAlreadyBuiltException; |
|
28 | } |
||
29 | |||
30 | $reference = $this |
||
31 | 2 | ->referenceFactory |
|
32 | 2 | ->createReference($text); |
|
33 | 2 | $this->references[] = $reference; |
|
34 | 2 | } |
|
35 | |||
36 | 4 | public function getLocator(): LocatorInterface |
|
43 | } |
||
44 | } |
||
45 |