MailMessage   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 84
Duplicated Lines 0 %

Coupling/Cohesion

Components 3
Dependencies 1

Test Coverage

Coverage 16.66%

Importance

Changes 0
Metric Value
dl 0
loc 84
c 0
b 0
f 0
wmc 4
lcom 3
cbo 1
ccs 2
cts 12
cp 0.1666
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A view() 0 7 1
A attach() 0 6 1
A attachData() 0 6 1
A data() 0 4 1
1
<?php
2
3
namespace Illuminate\Notifications\Messages;
4
5
class MailMessage extends SimpleMessage
6
{
7
    /**
8
     * The view for the message.
9
     *
10
     * @var string
11
     */
12
    public $view = 'notifications::email';
13
14
    /**
15
     * The view data for the message.
16
     *
17
     * @var array
18
     */
19
    public $viewData = [];
20
21
    /**
22
     * The attachments for the message.
23
     *
24
     * @var array
25
     */
26
    public $attachments = [];
27
28
    /**
29
     * The raw attachments for the message.
30
     *
31
     * @var array
32
     */
33
    public $rawAttachments = [];
34
35
    /**
36
     * Set the view for the mail message.
37
     *
38
     * @param  string  $view
39
     * @param  array  $data
40
     * @return $this
41
     */
42
    public function view($view, array $data = [])
43
    {
44
        $this->view = $view;
45
        $this->viewData = $data;
46
47
        return $this;
48
    }
49
50
    /**
51
     * Attach a file to the message.
52
     *
53
     * @param  string  $file
54
     * @param  array  $options
55
     * @return $this
56
     */
57
    public function attach($file, array $options = [])
58
    {
59
        $this->attachments[] = compact('file', 'options');
60
61
        return $this;
62
    }
63
64
    /**
65
     * Attach in-memory data as an attachment.
66
     *
67
     * @param  string  $data
68
     * @param  string  $name
69
     * @param  array  $options
70
     * @return $this
71
     */
72
    public function attachData($data, $name, array $options = [])
73
    {
74
        $this->rawAttachments[] = compact('data', 'name', 'options');
75
76
        return $this;
77
    }
78
79
    /**
80
     * Get the data array for the mail message.
81
     *
82
     * @return array
83
     */
84 1
    public function data()
85
    {
86 1
        return array_merge($this->toArray(), $this->viewData);
87
    }
88
}
89