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::isValidNotificationClass()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3.0416

Importance

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