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

CouldNotSendNotification   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 0
loc 40
ccs 0
cts 19
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A invalidMessageObject() 0 8 2
A invalidReceiver() 0 6 1
A notificationMethodNotExists() 0 7 2
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