Shield   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 30
c 0
b 0
f 0
wmc 3
lcom 1
cbo 2
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A handle() 0 8 2
1
<?php
2
3
namespace Clarkeash\Shield\Http\Middleware;
4
5
use Clarkeash\Shield\Manager;
6
use Closure;
7
use Illuminate\Http\Response;
8
9
class Shield
10
{
11
    /**
12
     * @var \Clarkeash\Shield\Manager
13
     */
14
    protected $manager;
15
16
    public function __construct(Manager $manager)
17
    {
18
        $this->manager = $manager;
19
    }
20
21
    /**
22
     * Handle an incoming request.
23
     *
24
     * @param  \Illuminate\Http\Request $request
25
     * @param  \Closure                 $next
26
     * @param string                    $service
27
     *
28
     * @return mixed
29
     */
30
    public function handle($request, Closure $next, string $service)
31
    {
32
        if($this->manager->passes($service, $request)) {
33
            return $next($request);
34
        }
35
36
        return Response::create(Response::$statusTexts[Response::HTTP_BAD_REQUEST], Response::HTTP_BAD_REQUEST);
37
    }
38
}
39