Url::check()   A
last analyzed

Complexity

Conditions 5
Paths 7

Size

Total Lines 26

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 26
rs 9.1928
c 0
b 0
f 0
cc 5
nc 7
nop 1
1
<?php
2
3
namespace Spinzar\Firewall\Middleware;
4
5
use Spinzar\Firewall\Abstracts\Middleware;
6
use Spinzar\Firewall\Events\AttackDetected;
7
8
class Url extends Middleware
9
{
10
    public function check($patterns)
11
    {
12
        $protected = false;
13
14
        if (!$inspections = config('firewall.middleware.' . $this->middleware . '.inspections')) {
15
            return $protected;
16
        }
17
18
        foreach ($inspections as $inspection) {
19
            if (!$this->request->is($inspection)) {
20
                continue;
21
            }
22
23
            $protected = true;
24
25
            break;
26
        }
27
28
        if ($protected) {
29
            $log = $this->log();
30
31
            event(new AttackDetected($log));
32
        }
33
34
        return $protected;
35
    }
36
}
37