NotifyUsers   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 20 4
1
<?php
2
3
namespace Spinzar\Firewall\Listeners;
4
5
use Spinzar\Firewall\Events\AttackDetected as Event;
6
use Spinzar\Firewall\Notifications\AttackDetected as Notification;
7
8
class NotifyUsers
9
{
10
    /**
11
     * Handle the event.
12
     *
13
     * @param Event $event
14
     *
15
     * @return void
16
     */
17
    public function handle(Event $event)
18
    {
19
        $model = config('firewall.models.user');
20
21
        if (!class_exists($model)) {
22
            return;
23
        }
24
25
        $emails = config('firewall.notifications.mail.to');
26
27
        foreach ($emails as $email) {
28
            $user = $model::where('email', $email)->first();
29
30
            if (empty($user)) {
31
                continue;
32
            }
33
34
            $user->notify(new Notification($event->log));
35
        }
36
    }
37
}
38