TextlocalChannel   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 28
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A send() 0 13 3
1
<?php
2
3
namespace NotificationChannels\Textlocal;
4
5
use Illuminate\Notifications\Notification;
6
7
class TextlocalChannel
8
{
9
    public function __construct(TextlocalClient $client)
10
    {
11
        $this->textlocal = $client;
0 ignored issues
show
Bug Best Practice introduced by
The property textlocal does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
12
    }
13
14
    /**
15
     * Send the given notification.
16
     *
17
     * @param mixed $notifiable
18
     * @param \Illuminate\Notifications\Notification $notification
19
     *
20
     * @throws \NotificationChannels\Textlocal\Exceptions\CouldNotSendNotification
21
     */
22
    public function send($notifiable, Notification $notification)
23
    {
24
        if (! $to = $notifiable->routeNotificationFor('textlocal')) {
25
            return;
26
        }
27
28
        $message = $notification->toTextlocal($notifiable);
0 ignored issues
show
Bug introduced by
The method toTextlocal() does not exist on Illuminate\Notifications\Notification. It seems like you code against a sub-type of said class. However, the method does not exist in Illuminate\Auth\Notifications\ResetPassword or Illuminate\Auth\Notifications\VerifyEmail. Are you sure you never get one of those? ( Ignorable by Annotation )

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

28
        /** @scrutinizer ignore-call */ 
29
        $message = $notification->toTextlocal($notifiable);
Loading history...
29
30
        if (is_string($message)) {
31
            $message = new TextlocalMessage($message);
32
        }
33
34
        return $this->textlocal->message($to, $message);
35
    }
36
}
37