Shield::handle()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
c 0
b 0
f 0
rs 9.4285
cc 2
eloc 4
nc 2
nop 3
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