Referrer   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 23
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A check() 0 20 4
1
<?php
2
3
namespace Spinzar\Firewall\Middleware;
4
5
use Spinzar\Firewall\Abstracts\Middleware;
6
use Spinzar\Firewall\Events\AttackDetected;
7
8
class Referrer extends Middleware
9
{
10
    public function check($patterns)
11
    {
12
        $status = false;
13
14
        if (!$blocked = config('firewall.middleware.' . $this->middleware . '.blocked')) {
15
            return $status;
16
        }
17
18
        if (in_array((string) $this->request->server('HTTP_REFERER'), (array) $blocked)) {
19
            $status = true;
20
        }
21
22
        if ($status) {
23
            $log = $this->log();
24
25
            event(new AttackDetected($log));
26
        }
27
28
        return $status;
29
    }
30
}
31