RouteProvider   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
eloc 9
dl 0
loc 35
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A provideRoutings() 0 9 2
1
<?php
2
3
4
namespace Xervice\Web\Business\Model\Provider;
5
6
7
use DataProvider\RouteCollectionDataProvider;
8
use Xervice\Routing\Business\RoutingFacade;
9
use Xervice\Web\Business\Dependency\Plugin\PluginCollection;
10
11
class RouteProvider implements RouteProviderInterface
12
{
13
    /**
14
     * @var PluginCollection
15
     */
16
    private $pluginCollection;
17
18
    /**
19
     * @var \Xervice\Routing\Business\RoutingFacade
20
     */
21
    private $routingFacade;
22
23
    /**
24
     * RouteProvider constructor.
25
     *
26
     * @param \Xervice\Web\Business\Dependency\Plugin\PluginCollection $pluginCollection
27
     * @param \Xervice\Routing\Business\RoutingFacade $routingFacade
28
     */
29 2
    public function __construct(
30
        PluginCollection $pluginCollection,
31
        RoutingFacade $routingFacade
32
    ) {
33 2
        $this->pluginCollection = $pluginCollection;
34 2
        $this->routingFacade = $routingFacade;
35 2
    }
36
37 2
    public function provideRoutings(): void
38
    {
39 2
        $routeCollection = new RouteCollectionDataProvider();
40
41 2
        foreach ($this->pluginCollection as $provider) {
42 2
            $routeCollection = $provider->handleRoutes($routeCollection);
43
        }
44
45 2
        $this->routingFacade->addRoutes($routeCollection);
46 2
    }
47
48
}