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.
Completed
Push — master ( c83ac9...577b76 )
by Freek
07:43 queued 04:24
created

FailedJobNotifier::notifyIfJobFailed()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

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