Test Failed
Pull Request — master (#1)
by
unknown
04:19
created

AfricasTalkingChannel::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
namespace NotificationChannels\AfricasTalking;
4
5
use AfricasTalking\SDK\AfricasTalking as AfricasTalkingSDK;
6
use Exception;
7
use Illuminate\Notifications\Notification;
8
use NotificationChannels\AfricasTalking\Exceptions\CouldNotSendNotification;
9
10
class AfricasTalkingChannel
11
{
12
    /** @var AfricasTalkingSDK */
13
    protected $africasTalking;
14
15
    /** @param AfricasTalkingSDK $africasTalking */
16
    public function __construct(AfricasTalkingSDK $africasTalking)
17
    {
18
        $this->africasTalking = $africasTalking;
19
    }
20
21
    /**
22
     * Send the given notification.
23
     *
24
     * @param mixed $notifiable
25
     * @param \Illuminate\Notifications\Notification $notification
26
     * @throws CouldNotSendNotification
27
     */
28
    public function send($notifiable, Notification $notification)
29
    {
30
        $message = $notification->toAfricasTalking($notifiable);
0 ignored issues
show
Bug introduced by
The method toAfricasTalking() does not exist on Illuminate\Notifications\Notification. It seems like you code against a sub-type of Illuminate\Notifications\Notification such as NotificationChannels\Afr...g\Test\TestNotification. ( Ignorable by Annotation )

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

30
        /** @scrutinizer ignore-call */ 
31
        $message = $notification->toAfricasTalking($notifiable);
Loading history...
31
     
32
        if (! $phoneNumber = $notifiable->routeNotificationFor('africasTalking')) {
33
            $phoneNumber = $notifiable->phone_number;
34
        }
35
36
        try {
37
            $this->africasTalking->send([
0 ignored issues
show
Bug introduced by
The method send() does not exist on AfricasTalking\SDK\AfricasTalking. ( Ignorable by Annotation )

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

37
            $this->africasTalking->/** @scrutinizer ignore-call */ 
38
                                   send([

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
38
                'to' => $phoneNumber,
39
                'message' => $message->getContent(),
40
                'from' => $message->getSender(),
41
            ]);
42
        } catch (Exception $e) {
43
            throw CouldNotSendNotification::serviceRespondedWithAnError($e->getMessage());
44
        }
45
    }
46
}
47