Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
87.50% covered (warning)
87.50%
7 / 8
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
RegisterBoundedContextActionContextBuilder
87.50% covered (warning)
87.50%
7 / 8
0.00% covered (danger)
0.00%
0 / 1
4.03
0.00% covered (danger)
0.00%
0 / 1
 process
87.50% covered (warning)
87.50%
7 / 8
0.00% covered (danger)
0.00%
0 / 1
4.03
1<?php
2namespace Apie\LaravelApie\ContextBuilders;
3
4use Apie\Core\BoundedContext\BoundedContextHashmap;
5use Apie\Core\Context\ApieContext;
6use Apie\Core\ContextBuilders\ContextBuilderInterface;
7
8class RegisterBoundedContextActionContextBuilder implements ContextBuilderInterface
9{
10    public function process(ApieContext $context): ApieContext
11    {
12        if (!$context->hasContext(BoundedContextHashmap::class)) {
13            return $context;
14        }
15        $hashmap = $context->getContext(BoundedContextHashmap::class);
16        foreach ($hashmap as $boundedContext) {
17            foreach ($boundedContext->actions as $action) {
18                $className = $action->getDeclaringClass()->name;
19                $context = $context->withContext($className, app($className));
20            }
21        }
22        return $context;
23    }
24}