Passed
Branch develop (ac3b98)
by Jorijn
02:01
created

SecurityMail   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Test Coverage

Coverage 27.78%

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 4
c 2
b 1
f 0
dl 0
loc 51
ccs 5
cts 18
cp 0.2778
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A build() 0 12 1
A getCheckResult() 0 3 1
A setCheckResult() 0 3 1
1
<?php
2
3
namespace Jorijn\LaravelSecurityChecker\Mailables;
4
5
use Illuminate\Bus\Queueable;
6
use Illuminate\Mail\Mailable;
7
use Illuminate\Queue\SerializesModels;
8
9
class SecurityMail extends Mailable
10
{
11
    use SerializesModels;
12
    use Queueable;
13
14
    protected $checkResult;
15
16
    /**
17
     * SecurityMail constructor.
18
     *
19
     * @param array $checkResult results from the Security Checker
20
     */
21 3
    public function __construct($checkResult)
22
    {
23 3
        $this->checkResult = $checkResult;
24 3
    }
25
26
    /**
27
     * Build the message.
28
     *
29
     * @return $this
30
     */
31
    public function build()
32
    {
33
        $packageCount = count($this->checkResult);
34
        $title = trans_choice('laravel-security-checker::messages.subject_new_vulnerabilities', $packageCount, [
35
            'count' => $packageCount
36
        ]);
37
        $subject = '['.config('app.name').'] '.$title;
38
39
        return $this->subject($subject)
40
            ->markdown('laravel-security-checker::security-mail', [
41
                'title'    => $title,
42
                'packages' => $this->checkResult
43
            ]);
44
    }
45
46
    /**
47
     * @return array
48
     */
49 3
    public function getCheckResult()
50
    {
51 3
        return $this->checkResult;
52
    }
53
54
    /**
55
     * @param array $checkResult
56
     */
57
    public function setCheckResult($checkResult)
58
    {
59
        $this->checkResult = $checkResult;
60
    }
61
}
62