Test Failed
Push — master ( 4e8d3d...451ac1 )
by Antonio Carlos
03:57 queued 48s
created

Mail   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 40
ccs 21
cts 21
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B send() 0 29 3
1
<?php
2
3
namespace PragmaRX\Firewall\Notifications\Channels;
4
5
use Carbon\Carbon;
6
use Illuminate\Notifications\Messages\MailMessage;
7
8
class Mail extends BaseChannel implements Contract
9
{
10
    /**
11
     * Send a message.
12
     *
13
     * @param $notifiable
14
     * @param $item
15
     *
16
     * @return null|\Illuminate\Notifications\Messages\SlackMessage
17
     */
18 4
    public function send($notifiable, $item)
19
    {
20 4
        $message = (new MailMessage())
21 4
            ->from(
22 4
                config('firewall.notifications.from.name'),
23 4
                config('firewall.notifications.from.icon_emoji')
24
            )
25 4
            ->subject(config('firewall.notifications.message.request_count.title'))
26 4
            ->line(sprintf(
27 4
                config('firewall.notifications.message.request_count.message'),
28 4
                $item['requestCount'],
29 4
                $item['firstRequestAt']->diffInSeconds(Carbon::now()),
30 4
                (string) $item['firstRequestAt']
31
            ))
32 4
            ->line(config('firewall.notifications.message.uri.title').': '.$item['server']['REQUEST_URI'])
33 4
            ->line(config('firewall.notifications.message.user_agent.title').': '.$item['userAgent'])
34 4
            ->line(config('firewall.notifications.message.blacklisted.title').': '.$item['isBlacklisted'] ? 'YES' : 'NO');
35
36 4
        $geo = $this->makeGeolocation($item);
37
38 4
        if ($item['geoIp']) {
39 3
            $message->line(config('firewall.notifications.message.geolocation.title')." - Latitude : {$geo['Latitude']}");
40 3
            $message->line(config('firewall.notifications.message.geolocation.title')." - Longitude : {$geo['Longitude']}");
41 3
            $message->line(config('firewall.notifications.message.geolocation.title')." - Country code : {$geo['Country code']}");
42 3
            $message->line(config('firewall.notifications.message.geolocation.title')." - Country name : {$geo['Country name']}");
43
        }
44
45 4
        return $message;
46
    }
47
}
48