Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
13 / 13
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
Menu
100.00% covered (success)
100.00%
13 / 13
100.00% covered (success)
100.00%
1 / 1
4
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
13 / 13
100.00% covered (success)
100.00%
1 / 1
4
1<?php
2
3namespace Apie\HtmlBuilders\Components\Layout;
4
5use Apie\HtmlBuilders\Components\BaseComponent;
6use Apie\HtmlBuilders\Configuration\CurrentConfiguration;
7
8class Menu extends BaseComponent
9{
10    public function __construct(CurrentConfiguration $currentConfiguration)
11    {
12        $menuItems = [];
13        $boundedContext = $currentConfiguration->getSelectedBoundedContext();
14        $apieContext = $currentConfiguration->getApieContext();
15        if ($boundedContext) {
16            foreach ($boundedContext->resources as $resource) {
17                if ($apieContext->appliesToContext($resource)) {
18                    $menuItems[] = [
19                        'url' => $currentConfiguration->getContextUrl('resource/' . $resource->getShortName()),
20                        'title' => $resource->getShortName(),
21                    ];
22                }
23            }
24        }
25        parent::__construct([
26            'menuItems' => $menuItems
27        ]);
28    }
29}