WhitelistMiddleware::handle()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

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