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 ( e97bb7...5f2eb5 )
by Pascal
10:40 queued 09:38
created

SendFailedNotification::handle()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 22
rs 9.568
c 0
b 0
f 0
cc 4
nc 4
nop 1
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