ReportMisuse   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 65
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 3
eloc 30
c 2
b 0
f 1
dl 0
loc 65
ccs 0
cts 34
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A build() 0 39 2
1
<?php
2
3
namespace DavideCasiraghi\LaravelEventsCalendar\Mail;
4
5
use Illuminate\Bus\Queueable;
6
use Illuminate\Mail\Mailable;
7
use Illuminate\Queue\SerializesModels;
8
9
class ReportMisuse extends Mailable
10
{
11
    use Queueable, SerializesModels;
0 ignored issues
show
introduced by
The trait Illuminate\Queue\SerializesModels requires some properties which are not provided by DavideCasiraghi\LaravelE...endar\Mail\ReportMisuse: $id, $relations, $class, $keyBy
Loading history...
12
13
    /**
14
     * The report instance.
15
     *
16
     * @var array
17
     */
18
    protected $report;
19
20
    /**
21
     * Create a new message instance.
22
     *
23
     * @return void
24
     */
25
    public function __construct(array $report)
26
    {
27
        $this->report = $report;
28
    }
29
30
    /**
31
     * Build the message.
32
     *
33
     * @return $this
34
     */
35
    public function build()
36
    {
37
        // Configure email parameters in .env file
38
        switch ($this->report['reason']) {
39
40
             /* Send email to the user that has created the event */
41
             case 'It is not translated in english':
42
43
                return $this->markdown('laravel-events-calendar::emails.misuse.organizer-event-not-english')
44
                 ->to($this->report['creatorEmail'])
45
                 ->from($this->report['senderEmail'], 'Global CI Calendar')
46
                 ->replyTo($this->report['senderEmail'], 'Global CI Calendar')
47
                 ->subject($this->report['subject'])
48
                 ->with([
49
                     'event_title' => $this->report['event_title'],
50
                     'event_id' => $this->report['event_id'],
51
                     'event_slug' => $this->report['event_slug'],
52
                     'reason' => $this->report['reason'],
53
                     'msg' => $this->report['message_misuse'],
54
                 ]);
55
56
                 break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
57
58
             /* Send email to the administrator */
59
             default:
60
61
                return $this->markdown('laravel-events-calendar::emails.misuse.administrator-report-misuse')
62
                    ->from('[email protected]', 'Global CI Calendar')
63
                    ->replyTo('[email protected]', 'Global CI Calendar')
64
                    ->subject($this->report['subject'])
65
                    ->with([
66
                        'event_title' => $this->report['event_title'],
67
                        'event_id' => $this->report['event_id'],
68
                        'event_slug' => $this->report['event_slug'],
69
                        'reason' => $this->report['reason'],
70
                        'msg' => $this->report['message_misuse'],
71
                    ]);
72
73
                 break;
74
         }
75
    }
76
}
77