Completed
Push — master ( bf73f1...8091ef )
by Iman
06:12
created

RouteAuthorizer::setGuardFor()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 1
dl 0
loc 5
ccs 4
cts 4
cp 1
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Imanghafoori\HeyMan;
4
5
use Illuminate\Routing\Events\RouteMatched;
6
use Illuminate\Support\Facades\Route;
7
use Imanghafoori\HeyMan\WatchingStrategies\RouterEventManager;
8
9
class RouteAuthorizer
10
{
11 87
    public function authorizeMatchedRoutes()
12
    {
13
        Route::matched(function (RouteMatched $eventObj) {
14 44
            $matchedRoute = [
15 44
                $eventObj->route->getName(),
16 28
                $eventObj->route->getActionName(),
17 26
                $eventObj->request->method().$eventObj->route->uri
18 87
            ];
19 87
20
            $closures = app(RouterEventManager::class)->start($matchedRoute);
21
            foreach ($closures as $cb) {
22
                foreach ($cb as $c) {
23
                    $c();
24 44
                }
25
            }
26 44
        });
27 44
    }
28
}
29