Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
ChainedRouteDefinitionsProvider
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
3 / 3
6
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getGlobalRoutes
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
3
 getActionsForBoundedContext
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2namespace Apie\Common\RouteDefinitions;
3
4use Apie\Common\Interfaces\GlobalRouteDefinitionProviderInterface;
5use Apie\Common\Interfaces\RouteDefinitionProviderInterface;
6use Apie\Core\BoundedContext\BoundedContext;
7use Apie\Core\Context\ApieContext;
8
9class ChainedRouteDefinitionsProvider implements GlobalRouteDefinitionProviderInterface
10{
11    /**
12     * @var RouteDefinitionProviderInterface[]
13     */
14    private array $routeDefinitions;
15
16    public function __construct(RouteDefinitionProviderInterface... $routeDefinitions)
17    {
18        $this->routeDefinitions = $routeDefinitions;
19    }
20
21    public function getGlobalRoutes(): ActionHashmap
22    {
23        $actionHashmap = new ActionHashmap();
24        foreach ($this->routeDefinitions as $routeDefinition) {
25            if ($routeDefinition instanceof GlobalRouteDefinitionProviderInterface) {
26                $actionHashmap = $actionHashmap->merge($routeDefinition->getGlobalRoutes());
27            }
28        }
29        return $actionHashmap;
30    }
31
32    public function getActionsForBoundedContext(BoundedContext $boundedContext, ApieContext $apieContext): ActionHashmap
33    {
34        $actionHashmap = new ActionHashmap();
35        foreach ($this->routeDefinitions as $routeDefinition) {
36            $actionHashmap = $actionHashmap->merge($routeDefinition->getActionsForBoundedContext($boundedContext, $apieContext));
37        }
38        return $actionHashmap;
39    }
40}