RouteClosureProvider   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A forRoute() 0 7 1
A forRouteId() 0 4 1
1
<?php
2
3
4
namespace ElementsFramework\DynamicRouting\Service;
5
6
7
use ElementsFramework\DynamicRouting\Model\DynamicRoute;
8
use Illuminate\Http\Request;
9
10
class RouteClosureProvider
11
{
12
13
    /**
14
     * @param DynamicRoute $route
15
     * @return \Closure
16
     */
17
    public static function forRoute(DynamicRoute $route)
18
    {
19
        return function(Request $request) use ($route) {
20
            $dispatcher = new RouteDispatcher();
21
            return $dispatcher->dispatchRouteToHandler($request, $route);
22
        };
23
    }
24
25
    /**
26
     * @param $routeId
27
     * @return \Closure
28
     */
29
    public static function forRouteId($routeId)
30
    {
31
        return self::forRoute(DynamicRoute::find($routeId));
32
    }
33
34
}