CouldNotSendNotification::invalidMessageObject()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 7
rs 10
1
<?php
2
3
namespace NotificationChannels\SmsRu\Exceptions;
4
5
use NotificationChannels\SmsRu\SmsRuMessage;
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 `".SmsRuMessage::class);
33
    }
34
}
35