CouldNotSendNotification   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 26
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A invalidReceiver() 0 3 1
A invalidMessageObject() 0 7 2
A missingFrom() 0 3 1
1
<?php
2
3
namespace NotificationChannels\TurboSms\Exceptions;
4
5
use NotificationChannels\TurboSms\TurboSmsMessage;
6
7
class CouldNotSendNotification extends \Exception
8
{
9
    /**
10
     * @return static
11
     */
12
    public static function missingFrom()
13
    {
14
        return new static('Notification was not sent. Missing `from` number.');
15
    }
16
17
    /**
18
     * @return CouldNotSendNotification
19
     */
20
    public static function invalidReceiver()
21
    {
22
        return new static("The notifiable did not have a receiving phone number. Add a <routeNotificationForSmsru>
23
            method or a <phone> attribute to your notifiable.");
24
    }
25
26
    public static function invalidMessageObject($message)
27
    {
28
        $className = get_class($message) ?: 'Unknown';
29
30
        return new static(
31
            "Notification was not sent. Message object class `{$className}` is invalid. It should
32
            be either `".TurboSmsMessage::class);
33
    }
34
}
35