Passed
Push — master ( 696cbf...968eef )
by Melech
05:53 queued 01:56
created

Message::getFromName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Valkyrja Framework package.
7
 *
8
 * (c) Melech Mizrachi <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Valkyrja\Mail\Data;
15
16
use Valkyrja\Mail\Data\Contract\Message as Contract;
17
18
/**
19
 * Class Message.
20
 *
21
 * @author Melech Mizrachi
22
 */
23
class Message implements Contract
24
{
25
    /**
26
     * The from email.
27
     *
28
     * @var string
29
     */
30
    protected string $fromEmail = '';
31
32
    /**
33
     * The from name.
34
     *
35
     * @var string
36
     */
37
    protected string $fromName = '';
38
39
    /**
40
     * The recipients.
41
     *
42
     * @var array<int, array{email: string, name: string}>
43
     */
44
    protected array $recipients = [];
45
46
    /**
47
     * The reply to recipients.
48
     *
49
     * @var array<int, array{email: string, name: string}>
50
     */
51
    protected array $replyToRecipients = [];
52
53
    /**
54
     * The copy recipients.
55
     *
56
     * @var array<int, array{email: string, name: string}>
57
     */
58
    protected array $copyRecipients = [];
59
60
    /**
61
     * The blind copy recipients.
62
     *
63
     * @var array<int, array{email: string, name: string}>
64
     */
65
    protected array $blindCopyRecipients = [];
66
67
    /**
68
     * The attachments.
69
     *
70
     * @var array<int, array{path: string, name: string}>
71
     */
72
    protected array $attachments = [];
73
74
    /**
75
     * The subject.
76
     *
77
     * @var string
78
     */
79
    protected string $subject = '';
80
81
    /**
82
     * The body.
83
     *
84
     * @var string
85
     */
86
    protected string $body = '';
87
88
    /**
89
     * Whether the message body is html.
90
     *
91
     * @var bool
92
     */
93
    protected bool $isHtml = false;
94
95
    /**
96
     * The plain body.
97
     *
98
     * @var string|null
99
     */
100
    protected string|null $plainBody = null;
101
102
    /**
103
     * @inheritDoc
104
     */
105
    public function getFromEmail(): string
106
    {
107
        return $this->fromEmail;
108
    }
109
110
    /**
111
     * @inheritDoc
112
     */
113
    public function getFromName(): string
114
    {
115
        return $this->fromName;
116
    }
117
118
    /**
119
     * @inheritDoc
120
     */
121
    public function setFrom(string $email, string $name = ''): static
122
    {
123
        $this->fromEmail = $email;
124
        $this->fromName  = $name;
125
126
        return $this;
127
    }
128
129
    /**
130
     * @inheritDoc
131
     */
132
    public function getRecipients(): array
133
    {
134
        return $this->recipients;
135
    }
136
137
    /**
138
     * @inheritDoc
139
     */
140
    public function addRecipient(string $email, string $name = ''): static
141
    {
142
        $this->recipients[] = [
143
            'email' => $email,
144
            'name'  => $name,
145
        ];
146
147
        return $this;
148
    }
149
150
    /**
151
     * @inheritDoc
152
     */
153
    public function getReplyToRecipients(): array
154
    {
155
        return $this->replyToRecipients;
156
    }
157
158
    /**
159
     * @inheritDoc
160
     */
161
    public function addReplyTo(string $email, string $name = ''): static
162
    {
163
        $this->replyToRecipients[] = [
164
            'email' => $email,
165
            'name'  => $name,
166
        ];
167
168
        return $this;
169
    }
170
171
    /**
172
     * @inheritDoc
173
     */
174
    public function getCopyRecipients(): array
175
    {
176
        return $this->copyRecipients;
177
    }
178
179
    /**
180
     * @inheritDoc
181
     */
182
    public function addCopyRecipient(string $email, string $name = ''): static
183
    {
184
        $this->copyRecipients[] = [
185
            'email' => $email,
186
            'name'  => $name,
187
        ];
188
189
        return $this;
190
    }
191
192
    /**
193
     * @inheritDoc
194
     */
195
    public function getBlindCopyRecipients(): array
196
    {
197
        return $this->blindCopyRecipients;
198
    }
199
200
    /**
201
     * @inheritDoc
202
     */
203
    public function addBlindCopyRecipient(string $email, string $name = ''): static
204
    {
205
        $this->blindCopyRecipients[] = [
206
            'email' => $email,
207
            'name'  => $name,
208
        ];
209
210
        return $this;
211
    }
212
213
    /**
214
     * @inheritDoc
215
     */
216
    public function getAttachments(): array
217
    {
218
        return $this->attachments;
219
    }
220
221
    /**
222
     * @inheritDoc
223
     */
224
    public function addAttachment(string $path, string $name = ''): static
225
    {
226
        $this->attachments[] = [
227
            'path' => $path,
228
            'name' => $name,
229
        ];
230
231
        return $this;
232
    }
233
234
    /**
235
     * @inheritDoc
236
     */
237
    public function getSubject(): string
238
    {
239
        return $this->subject;
240
    }
241
242
    /**
243
     * @inheritDoc
244
     */
245
    public function setSubject(string $subject): static
246
    {
247
        $this->subject = $subject;
248
249
        return $this;
250
    }
251
252
    /**
253
     * @inheritDoc
254
     */
255
    public function getBody(): string
256
    {
257
        return $this->body;
258
    }
259
260
    /**
261
     * @inheritDoc
262
     */
263
    public function setBody(string $body): static
264
    {
265
        $this->body = $body;
266
267
        return $this;
268
    }
269
270
    /**
271
     * @inheritDoc
272
     */
273
    public function isHtml(): bool
274
    {
275
        return $this->isHtml;
276
    }
277
278
    /**
279
     * @inheritDoc
280
     */
281
    public function setIsHtml(bool $isHtml = true): static
282
    {
283
        $this->isHtml = $isHtml;
284
285
        return $this;
286
    }
287
288
    /**
289
     * @inheritDoc
290
     */
291
    public function getPlainBody(): string|null
292
    {
293
        return $this->plainBody;
294
    }
295
296
    /**
297
     * @inheritDoc
298
     */
299
    public function setPlainBody(string|null $plainBody = null): static
300
    {
301
        $this->plainBody = $plainBody;
302
303
        return $this;
304
    }
305
}
306