GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

FailedJobNotifier::shouldSendNotification()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 1
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
1
<?php
2
3
namespace Spatie\FailedJobMonitor;
4
5
use Illuminate\Notifications\Notification as IlluminateNotification;
6
use Illuminate\Queue\Events\JobFailed;
7
use Illuminate\Queue\QueueManager;
8
use Spatie\FailedJobMonitor\Exceptions\InvalidConfiguration;
9
10
class FailedJobNotifier
11
{
12
    public function register()
13
    {
14
        app(QueueManager::class)->failing(function (JobFailed $event) {
15
            $notifiable = app(config('failed-job-monitor.notifiable'));
16
17
            $notification = app(config('failed-job-monitor.notification'))->setEvent($event);
18
19
            if (! $this->isValidNotificationClass($notification)) {
20
                throw InvalidConfiguration::notificationClassInvalid(get_class($notification));
21
            }
22
23
            if ($this->shouldSendNotification($notification)) {
24
                $notifiable->notify($notification);
25
            }
26
        });
27
    }
28
29
    public function isValidNotificationClass($notification): bool
30
    {
31
        if (get_class($notification) === Notification::class) {
32
            return true;
33
        }
34
35
        if (is_subclass_of($notification, IlluminateNotification::class)) {
36
            return true;
37
        }
38
39
        return false;
40
    }
41
42
    public function shouldSendNotification($notification)
43
    {
44
        $callable = config('failed-job-monitor.notificationFilter');
45
46
        if (! is_callable($callable)) {
47
            return true;
48
        }
49
50
        return $callable($notification);
51
    }
52
}
53