Completed
Push — fetcher_factories ( 10a56f...fd93ea )
by David
13:44
created

SplashMiddleware   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 3
c 3
b 0
f 0
lcom 0
cbo 2
dl 0
loc 15
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 3
1
<?php
2
3
namespace Mouf\Mvc\Splash;
4
5
use Mouf\Mvc\Splash\Routers\RouterInterface;
6
use Mouf\Mvc\Splash\Controllers\Controller;
7
use Zend\Stratigility\MiddlewarePipe;
8
9
/**
10
 * The SplashMiddleware class is the root of the Splash framework.<br/>
11
 * It is in charge of binding an Url to a Controller.<br/>
12
 * There is one and only one instance of Splash per web application.<br/>
13
 * The name of the instance MUST be "splashMiddleware".<br/>
14
 * <br/>
15
 * The SplashMiddleware component has several ways to bind an URL to a Controller.<br/>
16
 * It can do so based on the @URL annotation, or based on the @Action annotation.<br/>
17
 * Check out the Splash documentation here:
18
 * <a href="https://github.com/thecodingmachine/mvc.splash/">https://github.com/thecodingmachine/mvc.splash/</a>.
19
 */
20
class SplashMiddleware extends MiddlewarePipe
21
{
22
    /**
23
     * @param RouterInterface[] $routers
24
     */
25
    public function __construct(array $routers)
26
    {
27
        parent::__construct();
28
        foreach ($routers as $router) {
29
            if ($router->isActive()) {
30
                $this->pipe($router->getPath(), $router->getMiddleware());
31
            }
32
        }
33
    }
34
}
35