RouteProvider::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 1
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
}