VerificationChannel::send()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 10
rs 10
cc 2
nc 2
nop 2
1
<?php
2
3
namespace Fouladgar\MobileVerification\Notifications\Channels;
4
5
use Fouladgar\MobileVerification\Contracts\SMSClient;
6
use Fouladgar\MobileVerification\Notifications\Messages\MobileVerificationMessage;
7
use Illuminate\Notifications\Notification;
8
9
class VerificationChannel
10
{
11
    /**
12
     * SMSClient (i.e. Nexmo).
13
     *
14
     * @var SMSClient
15
     */
16
    protected $SMSClient;
17
18
    /**
19
     * VerificationChannel constructor.
20
     *
21
     * @param SMSClient $SMSClient
22
     */
23
    public function __construct(SMSClient $SMSClient)
24
    {
25
        $this->SMSClient = $SMSClient;
26
    }
27
28
    /**
29
     * Send the given notification.
30
     *
31
     * @param $notifiable
32
     * @param Notification $notification
33
     *
34
     * @return mixed|void
35
     */
36
    public function send($notifiable, Notification $notification)
37
    {
38
        if (! $notifiable->routeNotificationFor('verification_mobile', $notification)) {
39
            return;
40
        }
41
42
        /** @var MobileVerificationMessage $message */
43
        $message = $notification->toMobile($notifiable);
0 ignored issues
show
Bug introduced by
The method toMobile() does not exist on Illuminate\Notifications\Notification. It seems like you code against a sub-type of Illuminate\Notifications\Notification such as Fouladgar\MobileVerifica...ifications\VerifyMobile. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

43
        /** @scrutinizer ignore-call */ 
44
        $message = $notification->toMobile($notifiable);
Loading history...
44
45
        return $this->SMSClient->sendMessage($message->getPayload());
46
    }
47
}
48