FormEntryReceived   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
eloc 16
c 1
b 0
f 0
dl 0
loc 53
ccs 16
cts 16
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A toMail() 0 12 2
A getSubject() 0 7 2
A __construct() 0 3 1
A via() 0 3 1
1
<?php
2
3
namespace FormEntries\Notifications;
4
5
use FormEntries\Forms\FormContent;
6
use Illuminate\Bus\Queueable;
7
use Illuminate\Contracts\Queue\ShouldQueue;
8
use Illuminate\Notifications\Messages\MailMessage;
9
use Illuminate\Notifications\Notification;
10
11
class FormEntryReceived extends Notification implements ShouldQueue
12
{
13
    use Queueable;
14
15
    public FormContent $content;
16
17
    public ?string $subject = null;
18
19 9
    public function __construct(FormContent $content)
20
    {
21 9
        $this->content = $content;
22
    }
23
24
    /**
25
     * Get the notification's delivery channels.
26
     *
27
     * @param mixed $notifiable
28
     *
29
     * @return array
30
     */
31 8
    public function via($notifiable = null)
0 ignored issues
show
Unused Code introduced by
The parameter $notifiable is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

31
    public function via(/** @scrutinizer ignore-unused */ $notifiable = null)

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

Loading history...
32
    {
33 8
        return ['mail'];
34
    }
35
36
    /**
37
     * Get the mail representation of the notification.
38
     *
39
     * @param mixed $notifiable
40
     *
41
     * @return MailMessage
42
     */
43 1
    public function toMail($notifiable)
0 ignored issues
show
Unused Code introduced by
The parameter $notifiable is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

43
    public function toMail(/** @scrutinizer ignore-unused */ $notifiable)

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

Loading history...
44
    {
45
        /** @var MailMessage $message */
46 1
        $message = (new MailMessage)
47 1
            ->subject($this->getSubject())
48 1
            ->greeting(trans('forms-entries::notification.form_content_greeting'))
49 1
            ->line(trans('forms-entries::notification.form_content_header'));
50 1
        foreach (explode("\n", $this->content->stringify()) as $line) {
51 1
            $message->line($line);
52
        }
53
54 1
        return $message;
55
    }
56
57 1
    protected function getSubject(): string
58
    {
59 1
        if ($this->subject) {
60 1
            return $this->subject;
61
        }
62
63 1
        return trans('forms-entries::notification.form_subject', ['name' => $this->content->formName()]);
64
    }
65
}
66