MailMessage::attach()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
c 0
b 0
f 0
ccs 0
cts 3
cp 0
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
crap 2
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