Passed
Push — master ( 6c48fd...75d922 )
by Orkhan
01:51
created

BlacklistMiddleware   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 4
c 1
b 0
f 0
dl 0
loc 18
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 7 3
1
<?php
2
3
namespace Orkhanahmadov\LaravelIpMiddleware;
4
5
use Closure;
6
use Illuminate\Support\Arr;
7
use Illuminate\Http\Request;
8
9
class BlacklistMiddleware extends Middleware
10
{
11
    /**
12
     * Handle an incoming request.
13
     *
14
     * @param Request $request
15
     * @param Closure $next
16
     * @param array $blacklist
17
     *
18
     * @return mixed
19
     */
20
    public function handle($request, Closure $next, ...$blacklist)
21
    {
22
        if ($this->shouldCheck() && in_array($this->realIp($request), Arr::flatten($blacklist))) {
23
            $this->application->abort($this->errorCode);
24
        }
25
26
        return $next($request);
27
    }
28
}
29