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