Completed
Push — master ( c9a5b8...803065 )
by Restu
11:14
created

functions.php ➔ dispatcherBasic()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 7
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 12
ccs 5
cts 5
cp 1
crap 1
rs 9.4285
1
<?php
2
namespace JayaCode\Framework\Core\Route;
3
4
use JayaCode\Framework\Core\Route\Collector\RegexRouteCollector;
5
use JayaCode\Framework\Core\Route\Dispatcher\Dispatcher;
6
use JayaCode\Framework\Core\Route\Dispatcher\RegexDispatcher;
7
8
if (!function_exists('JayaCode\Framework\Core\RouteRoute\dispatcherBasic')) {
9
10
    /**
11
     * @param callable $definitionCollection
12
     * @param array $options
13
     * @return Dispatcher
14
     */
15
    function dispatcherBasic(callable $definitionCollection, $options = [])
16
    {
17
        $options += [
18 3
            "dispatcher" => RegexDispatcher::class,
19
            "routeCollection" => RegexRouteCollector::class
20 3
        ];
21
22 3
        $routeCollection = new $options["routeCollection"]();
23 3
        $definitionCollection($routeCollection);
24
25 3
        return new $options['dispatcher']($routeCollection);
26
    }
27
}
28