WhitelistMiddleware   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 4
c 0
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\Http\Request;
7
8
class WhitelistMiddleware extends Middleware
9
{
10
    /**
11
     * Handle an incoming request.
12
     *
13
     * @param Request $request
14
     * @param Closure $next
15
     * @param array $whitelist
16
     *
17
     * @return mixed
18
     */
19
    public function handle($request, Closure $next, ...$whitelist)
20
    {
21
        if ($this->shouldCheck() && ! in_array($this->clientIp($request), $this->ipList($whitelist))) {
22
            $this->abort();
23
        }
24
25
        return $next($request);
26
    }
27
}
28