Total Complexity | 8 |
Total Lines | 62 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
15 | class EngineBuilder |
||
16 | { |
||
17 | /** |
||
18 | * @var FilterInterface |
||
19 | */ |
||
20 | private $filter; |
||
21 | |||
22 | /** |
||
23 | * @var RunnerInterface |
||
24 | */ |
||
25 | private $runner; |
||
26 | |||
27 | /** |
||
28 | * @var bool |
||
29 | */ |
||
30 | private $ignoreUnknownAnnotations = false; |
||
31 | |||
32 | public function setIgnoreUnknownAnnotations($flag = true) |
||
35 | } |
||
36 | |||
37 | public function setFilter(FilterInterface $filter): self |
||
38 | { |
||
39 | $this->filter = $filter; |
||
40 | return $this; |
||
41 | } |
||
42 | |||
43 | public function setRunner(RunnerInterface $runner): self |
||
44 | { |
||
45 | $this->runner = $runner; |
||
46 | return $this; |
||
47 | } |
||
48 | |||
49 | public function buildEngine(): Engine |
||
50 | { |
||
51 | return new Engine( |
||
52 | new Parser, |
||
53 | new ExampleFactory( |
||
54 | new ExpectationFactory, |
||
55 | $this->getFilter(), |
||
56 | $this->ignoreUnknownAnnotations |
||
57 | ), |
||
58 | new ExampleTester( |
||
59 | $this->getRunner(), |
||
60 | new ExpectationEvaluator |
||
61 | ) |
||
62 | ); |
||
63 | } |
||
64 | |||
65 | private function getFilter(): FilterInterface |
||
66 | { |
||
67 | return $this->filter ?: new NullFilter; |
||
68 | } |
||
69 | |||
70 | private function getRunner(): RunnerInterface |
||
77 | } |
||
78 | } |
||
79 |