Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
92.86% |
13 / 14 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
StorageMetadataBuilder | |
92.86% |
13 / 14 |
|
50.00% |
1 / 2 |
4.01 | |
0.00% |
0 / 1 |
__construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
generateCode | |
92.31% |
12 / 13 |
|
0.00% |
0 / 1 |
3.00 |
1 | <?php |
2 | namespace Apie\StorageMetadataBuilder; |
3 | |
4 | use Apie\Core\BoundedContext\BoundedContextHashmap; |
5 | use Apie\StorageMetadataBuilder\Interfaces\BootGeneratedCodeInterface; |
6 | use Apie\StorageMetadataBuilder\Interfaces\PostRunGeneratedCodeContextInterface; |
7 | use Apie\StorageMetadataBuilder\Interfaces\RunGeneratedCodeContextInterface; |
8 | use Apie\StorageMetadataBuilder\Lists\GeneratedCodeHashmap; |
9 | use Apie\StorageMetadataBuilder\Mediators\GeneratedCode; |
10 | use Apie\StorageMetadataBuilder\Mediators\GeneratedCodeContext; |
11 | |
12 | final class StorageMetadataBuilder |
13 | { |
14 | public function __construct( |
15 | private readonly BoundedContextHashmap $boundedContextHashmap, |
16 | private readonly BootGeneratedCodeInterface $bootGeneratedCode, |
17 | private readonly RunGeneratedCodeContextInterface $runGeneratedCode, |
18 | private readonly PostRunGeneratedCodeContextInterface $postRunGeneratedCode |
19 | ) { |
20 | } |
21 | |
22 | public function generateCode(): GeneratedCode |
23 | { |
24 | $code = new GeneratedCode( |
25 | $this->boundedContextHashmap, |
26 | new GeneratedCodeHashmap([ |
27 | ]), |
28 | ); |
29 | $this->bootGeneratedCode->boot($code); |
30 | while ($code->hasTodos()) { |
31 | $context = $code->getNextTodo(); |
32 | $this->runGeneratedCode->run($context); |
33 | } |
34 | if (!isset($context)) { |
35 | $context = new GeneratedCodeContext($code, null); |
36 | } |
37 | $this->postRunGeneratedCode->postRun($context); |
38 | |
39 | return $code; |
40 | } |
41 | } |