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

Notification   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 6
dl 0
loc 57
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A via() 0 4 1
A setEvent() 0 6 1
A toMail() 0 10 1
A toSlack() 0 14 1
1
<?php
2
3
namespace Spatie\FailedJobMonitor;
4
5
use Illuminate\Queue\Events\JobFailed;
6
use Illuminate\Notifications\Messages\MailMessage;
7
use Illuminate\Notifications\Messages\SlackMessage;
8
use Illuminate\Notifications\Messages\SlackAttachment;
9
use Illuminate\Notifications\Notification as IlluminateNotification;
10
11
class Notification extends IlluminateNotification
12
{
13
    /** @var \Illuminate\Queue\Events\JobFailed */
14
    protected $event;
15
16
    public function via($notifiable): array
0 ignored issues
show
Unused Code introduced by
The parameter $notifiable is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
17
    {
18
        return config('laravel-failed-job-monitor.channels');
19
    }
20
21
    public function setEvent(JobFailed $event): self
22
    {
23
        $this->event = $event;
24
25
        return $this;
26
    }
27
28
    /**
29
     * Get the mail representation of the notification.
30
     *
31
     * @param  mixed $notifiable
32
     *
33
     * @return \Illuminate\Notifications\Messages\MailMessage
34
     */
35
    public function toMail($notifiable): MailMessage
0 ignored issues
show
Unused Code introduced by
The parameter $notifiable is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
36
    {
37
        return (new MailMessage)
38
            ->error()
39
            ->subject('A job failed at '.env('APP_URL'))
40
            ->line('Exception message:'.$this->event->exception->getMessage())
41
            ->line('Job class: '.$this->event->job->resolveName())
42
            ->line('Job body: '.$this->event->job->getRawBody())
43
            ->line('Exception: '.$this->event->exception->getTraceAsString());
44
    }
45
46
    /**
47
     * Get the Slack representation of the notification.
48
     *
49
     * @param  mixed $notifiable
50
     *
51
     * @return \Illuminate\Notifications\Messages\SlackMessage
52
     */
53
    public function toSlack($notifiable): SlackMessage
0 ignored issues
show
Unused Code introduced by
The parameter $notifiable is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
54
    {
55
        return (new SlackMessage)
56
            ->error()
57
            ->content('A job failed at '.env('APP_URL'))
58
            ->attachment(function (SlackAttachment $attachment) {
59
                $attachment->fields([
60
                    'Exception message' => $this->event->exception->getMessage(),
61
                    'Job class' => $this->event->job->resolveName(),
62
                    'Job body' => $this->event->job->getRawBody(),
63
                    'Exception' => $this->event->exception->getTraceAsString(),
64
                ]);
65
            });
66
    }
67
}
68