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.

SendFailedNotification::handle()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 21
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 10
nc 4
nop 1
dl 0
loc 21
rs 9.9332
c 0
b 0
f 0
1
<?php
2
3
namespace ProtoneMedia\ApiHealth\Listeners;
4
5
use ProtoneMedia\ApiHealth\Checkers\CheckerSendsNotifications;
6
use ProtoneMedia\ApiHealth\Events\CheckerHasFailed;
7
use ProtoneMedia\ApiHealth\Storage\CheckerState;
8
9
class SendFailedNotification
10
{
11
    use SendsNotifications;
12
13
    /**
14
     * Sends the failed notification if needed.
15
     *
16
     * @param  \ProtoneMedia\ApiHealth\Events\CheckerHasFailed $event
17
     */
18
    public function handle($event)
19
    {
20
        $checker = $event->checker;
21
22
        if (!$checker instanceof CheckerSendsNotifications) {
23
            return;
24
        }
25
26
        $state = new CheckerState($checker);
27
28
        if (!$state->shouldSentFailedNotification()) {
29
            return;
30
        }
31
32
        $notificationClass = $checker->failedNotificationClass();
33
34
        $notification = $this->sendNotification(
35
            new $notificationClass($checker, $event->exception, $event->failedData)
36
        );
37
38
        $notification ? $state->markSentFailedNotification($notification) : null;
39
    }
40
}
41