Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
92.86% covered (success)
92.86%
13 / 14
50.00% covered (danger)
50.00%
1 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
StorageMetadataBuilder
92.86% covered (success)
92.86%
13 / 14
50.00% covered (danger)
50.00%
1 / 2
4.01
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 generateCode
92.31% covered (success)
92.31%
12 / 13
0.00% covered (danger)
0.00%
0 / 1
3.00
1<?php
2namespace Apie\StorageMetadataBuilder;
3
4use Apie\Core\BoundedContext\BoundedContextHashmap;
5use Apie\StorageMetadataBuilder\Interfaces\BootGeneratedCodeInterface;
6use Apie\StorageMetadataBuilder\Interfaces\PostRunGeneratedCodeContextInterface;
7use Apie\StorageMetadataBuilder\Interfaces\RunGeneratedCodeContextInterface;
8use Apie\StorageMetadataBuilder\Lists\GeneratedCodeHashmap;
9use Apie\StorageMetadataBuilder\Mediators\GeneratedCode;
10use Apie\StorageMetadataBuilder\Mediators\GeneratedCodeContext;
11
12final 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}