Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
8 / 8 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| ConsoleCommandFactory | |
100.00% |
8 / 8 |
|
100.00% |
2 / 2 |
4 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| create | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
3 | |||
| 1 | <?php |
| 2 | namespace Apie\Common\Wrappers; |
| 3 | |
| 4 | use Apie\Console\ConsoleCommandFactory as ConsoleConsoleCommandFactory; |
| 5 | use Apie\Core\BoundedContext\BoundedContext; |
| 6 | use Apie\Core\BoundedContext\BoundedContextHashmap; |
| 7 | use Apie\Core\ContextBuilders\ContextBuilderFactory; |
| 8 | use Generator; |
| 9 | use Symfony\Component\Console\Application; |
| 10 | |
| 11 | final class ConsoleCommandFactory |
| 12 | { |
| 13 | public function __construct( |
| 14 | private readonly ConsoleConsoleCommandFactory $factory, |
| 15 | private readonly ContextBuilderFactory $contextBuilderFactory, |
| 16 | private readonly BoundedContextHashmap $boundedContextHashmap |
| 17 | ) { |
| 18 | } |
| 19 | |
| 20 | public function create(Application $application): Generator |
| 21 | { |
| 22 | foreach ($this->boundedContextHashmap as $boundedContext) { |
| 23 | $context = $this->contextBuilderFactory->createGeneralContext([ |
| 24 | Application::class => $application, |
| 25 | BoundedContext::class => $boundedContext |
| 26 | ]); |
| 27 | foreach ($this->factory->createForBoundedContext($boundedContext, $context) as $command) { |
| 28 | yield $command; |
| 29 | } |
| 30 | } |
| 31 | } |
| 32 | } |