Completed
Push — master ( 453b67...10e484 )
by Abdelrahman
11:57
created

AuthenticationLockoutNotification   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 50
rs 10
c 1
b 0
f 0
wmc 3
lcom 1
cbo 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A via() 0 4 1
A toMail() 0 11 1
1
<?php
2
3
/*
4
 * NOTICE OF LICENSE
5
 *
6
 * Part of the Rinvex Fort Package.
7
 *
8
 * This source file is subject to The MIT License (MIT)
9
 * that is bundled with this package in the LICENSE file.
10
 *
11
 * Package: Rinvex Fort Package
12
 * License: The MIT License (MIT)
13
 * Link:    https://rinvex.com
14
 */
15
16
namespace Rinvex\Fort\Notifications;
17
18
use Carbon\Carbon;
19
use Illuminate\Http\Request;
20
use Illuminate\Support\Facades\Lang;
21
use Illuminate\Notifications\Notification;
22
use Illuminate\Notifications\Messages\MailMessage;
23
24
class AuthenticationLockoutNotification extends Notification
25
{
26
    /**
27
     * The request instance.
28
     *
29
     * @var \Illuminate\Http\Request
30
     */
31
    public $request;
32
33
    /**
34
     * Create a notification instance.
35
     *
36
     * @param \Illuminate\Http\Request $request
37
     *
38
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
39
     */
40
    public function __construct(Request $request)
0 ignored issues
show
Bug introduced by
You have injected the Request via parameter $request. This is generally not recommended as there might be multiple instances during a request cycle (f.e. when using sub-requests). Instead, it is recommended to inject the RequestStack and retrieve the current request each time you need it via getCurrentRequest().
Loading history...
41
    {
42
        $this->request = $request;
43
    }
44
45
    /**
46
     * Get the notification's channels.
47
     *
48
     * @param mixed $notifiable
49
     *
50
     * @return array|string
51
     */
52
    public function via($notifiable)
0 ignored issues
show
Unused Code introduced by
The parameter $notifiable is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
53
    {
54
        return ['mail'];
55
    }
56
57
    /**
58
     * Build the mail representation of the notification.
59
     *
60
     * @return \Illuminate\Notifications\Messages\MailMessage
61
     */
62
    public function toMail()
63
    {
64
        return (new MailMessage)
65
            ->subject(Lang::get('rinvex.fort::email.auth.lockout.subject'))
66
            ->line(Lang::get('rinvex.fort::email.auth.lockout.intro', [
67
                'created_at' => new Carbon(),
68
                'ip'         => $this->request->ip(),
69
                'agent'      => $this->request->server('HTTP_USER_AGENT'),
70
            ]))
71
            ->line(Lang::get('rinvex.fort::email.auth.lockout.outro'));
72
    }
73
}
74