Ip::check()   A
last analyzed

Complexity

Conditions 2
Paths 3

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 9.7998
c 0
b 0
f 0
cc 2
nc 3
nop 1
1
<?php
2
3
namespace Spinzar\Firewall\Middleware;
4
5
use Spinzar\Firewall\Abstracts\Middleware;
6
use Spinzar\Firewall\Models\Ip as Model;
7
use Illuminate\Database\QueryException;
8
9
class Ip extends Middleware
10
{
11
    public function check($patterns)
12
    {
13
        $status = false;
14
15
        try {
16
            $ip = config('firewall.models.ip', Model::class);
17
            $status = $ip::blocked($this->ip())->pluck('id')->first();
18
        } catch (QueryException $e) {
19
            // Base table or view not found
20
            //$status = ($e->getCode() == '42S02') ? false : true;
21
        }
22
23
        return $status;
24
    }
25
}
26