ExceptionOccured   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 7
eloc 26
c 2
b 1
f 0
dl 0
loc 56
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
B build() 0 35 6
A __construct() 0 3 1
1
<?php
2
3
namespace App\Mail;
4
5
use Illuminate\Bus\Queueable;
6
use Illuminate\Mail\Mailable;
7
use Illuminate\Queue\SerializesModels;
8
9
class ExceptionOccured 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 App\Mail\ExceptionOccured: $id, $relations, $class, $keyBy
Loading history...
12
13
    private $content;
14
15
    /**
16
     * Create a new message instance.
17
     *
18
     * @return void
19
     */
20
    public function __construct($content)
21
    {
22
        $this->content = $content;
23
    }
24
25
    /**
26
     * Build the message.
27
     *
28
     * @return $this
29
     */
30
    public function build()
31
    {
32
        $emailsTo = str_getcsv(config('exceptions.emailExceptionsTo'), ',');
33
        $ccEmails = str_getcsv(config('exceptions.emailExceptionCCto'), ',');
34
        $bccEmails = str_getcsv(config('exceptions.emailExceptionBCCto'), ',');
35
        $fromSender = config('exceptions.emailExceptionFrom');
36
        $subject = config('exceptions.emailExceptionSubject');
37
38
        if ($emailsTo[0] === null) {
39
            $emailsTo = config('exceptions.emailExceptionsToDefault');
40
        }
41
42
        if ($ccEmails[0] === null) {
43
            $ccEmails = config('exceptions.emailExceptionCCtoDefault');
44
        }
45
46
        if ($bccEmails[0] === null) {
47
            $bccEmails = config('exceptions.emailExceptionBCCtoDefault');
48
        }
49
50
        if (! $fromSender) {
51
            $fromSender = config('exceptions.emailExceptionFromDefault');
52
        }
53
54
        if (! $subject) {
55
            $subject = config('exceptions.emailExceptionSubjectDefault');
56
        }
57
58
        return $this->from($fromSender)
59
                    ->to($emailsTo)
60
                    ->cc($ccEmails)
61
                    ->bcc($bccEmails)
62
                    ->subject($subject)
63
                    ->view(config('exceptions.emailExceptionView'))
64
                    ->with('content', $this->content);
65
    }
66
}
67