DispatcherChain   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 31
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A dispatch() 0 10 3
1
<?php
2
3
namespace Mosaic\Routing\Dispatchers;
4
5
use Mosaic\Routing\Route;
6
7
class DispatcherChain implements Dispatcher
8
{
9
    /**
10
     * @var Dispatcher[]
11
     */
12
    private $dispatchers;
13
14
    /**
15
     * @param $dispatchers
16
     */
17 4
    public function __construct(Dispatcher ...$dispatchers)
18
    {
19 4
        $this->dispatchers = $dispatchers;
20 4
    }
21
22
    /**
23
     * @param  Route    $route
24
     * @param  callable $next
25
     * @return mixed
26
     */
27 4
    public function dispatch(Route $route, callable $next)
28
    {
29 4
        foreach ($this->dispatchers as $dispatcher) {
30 4
            $response = $dispatcher->dispatch($route, $next);
31
32 4
            if (!$response instanceof Route) {
33 4
                return $response;
34
            }
35
        }
36 1
    }
37
}
38