Completed
Push — master ( b5b506...db6c8e )
by Rafael
02:14
created

notificationMethodNotExists()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 0
cts 6
cp 0
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 6
1
<?php
2
3
namespace NotificationChannels\TotalVoice\Exceptions;
4
5
use NotificationChannels\TotalVoice\TotalVoiceMessage;
6
use NotificationChannels\TotalVoice\TotalVoiceAudioMessage;
7
8
class CouldNotSendNotification extends \Exception
9
{
10
    /**
11
     * @param mixed $message
12
     *
13
     * @return static
14
     */
15
    public static function invalidMessageObject($message)
16
    {
17
        $className = get_class($message) ?: 'Unknown';
18
19
        return new static(
20
            "Notification was not sent. Message object class `{$className}` is invalid. It should
21
            be either `".TotalVoiceMessage::class.'` or `'.TotalVoiceAudioMessage::class.'`');
22
    }
23
24
    /**
25
     * @return static
26
     */
27
    public static function invalidReceiver()
28
    {
29
        return new static(
30
            'The notifiable did not have a receiving phone number. Add a routeNotificationForTotalVoice
31
            method or a phone_number attribute to your notifiable.');
32
    }
33
34
    /**
35
     * @param mixed $notification
36
     *
37
     * @return static
38
     */
39
    public static function notificationMethodNotExists($notification)
40
    {
41
        $className = get_class($notification) ?: 'Unknown';
42
43
        return new static(
44
            "Notification was not sent. Method toTotalVoice() not exists on `{$className} notification class`.");
45
    }
46
    
47
}
48