Completed
Push — master ( 20a6e3...887da8 )
by Abdelrahman
04:09 queued 02:12
created

PhoneVerificationNotification::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cortex\Auth\Notifications;
6
7
use Illuminate\Bus\Queueable;
8
use Illuminate\Notifications\Notification;
9
use Illuminate\Contracts\Queue\ShouldQueue;
10
use NotificationChannels\Authy\AuthyChannel;
11
use NotificationChannels\Authy\AuthyMessage;
12
13
class PhoneVerificationNotification extends Notification implements ShouldQueue
14
{
15
    use Queueable;
16
17
    /**
18
     * The notification method (sms/call).
19
     *
20
     * @var string
21
     */
22
    public $method;
23
24
    /**
25
     * Determine whether to force the notification over cellphone network.
26
     *
27
     * @var bool
28
     */
29
    public $force;
30
31
    /**
32
     * Create a notification instance.
33
     *
34
     * @param string $method
35
     * @param bool   $force
36
     */
37
    public function __construct(string $method = 'sms', bool $force = false)
38
    {
39
        $this->method = $method;
40
        $this->force = $force;
41
    }
42
43
    /**
44
     * Get the notification's channels.
45
     *
46
     * @param mixed $notifiable
47
     *
48
     * @return array|string
49
     */
50
    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...
51
    {
52
        return [AuthyChannel::class];
53
    }
54
55
    /**
56
     * Build the mail representation of the notification.
57
     *
58
     * @return \NotificationChannels\Authy\AuthyMessage
59
     */
60
    public function toAuthy(): AuthyMessage
61
    {
62
        $message = AuthyMessage::create()->method($this->method);
63
64
        if ($this->force) {
65
            $message->force();
66
        }
67
68
        return $message;
69
    }
70
}
71