Completed
Push — master ( 634d7f...089f92 )
by Gabriel
02:37
created

Email::getReplyTo()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 2
eloc 2
nc 2
nop 0
1
<?php
2
3
namespace Omnimail;
4
5
class Email implements EmailInterface
6
{
7
    /**
8
     * @var array
9
     */
10
    protected $to = [];
11
12
    /**
13
     * @var array
14
     */
15
    protected $cc = [];
16
17
    /**
18
     * @var array
19
     */
20
    protected $bcc = [];
21
22
    /**
23
     * @var array
24
     */
25
    protected $replyTo = [];
26
27
    /**
28
     * @var array
29
     */
30
    protected $attachements = [];
31
32
    /**
33
     * @var array
34
     */
35
    protected $from;
36
37
    /**
38
     * @var string
39
     */
40
    protected $subject;
41
42
    /**
43
     * @var string
44
     */
45
    protected $textBody;
46
47
    /**
48
     * @var string
49
     */
50
    protected $htmlBody;
51
52
    /**
53
     * @return string
54
     */
55
    public function getTextBody()
56
    {
57
        return $this->textBody;
58
    }
59
60
    /**
61
     * @param string $textBody
62
     * @return $this
63
     */
64
    public function setTextBody($textBody)
65
    {
66
        $this->textBody = $textBody;
67
        return $this;
68
    }
69
70
    /**
71
     * @return string
72
     */
73
    public function getHtmlBody()
74
    {
75
        return $this->textBody;
76
    }
77
78
    /**
79
     * @param string $htmlBody
80
     * @return $this
81
     */
82
    public function setHtmlBody($htmlBody)
83
    {
84
        $this->htmlBody = $htmlBody;
85
        return $this;
86
    }
87
88
    /**
89
     * @return string
90
     */
91
    public function getFrom()
92
    {
93
        return $this->from;
94
    }
95
96
    /**
97
     * @param string $email
98
     * @param string|null $name
99
     * @return $this
100
     */
101
    public function setFrom($email, $name = null)
102
    {
103
        $this->from = ['email' => $email, 'name' => $name];
104
        return $this;
105
    }
106
107
    /**
108
     * @return string
109
     */
110
    public function getSubject()
111
    {
112
        return $this->subject;
113
    }
114
115
    /**
116
     * @param string $subject
117
     * @return $this
118
     */
119
    public function setSubject($subject)
120
    {
121
        $this->subject = $subject;
122
        return $this;
123
    }
124
125
    /**
126
     * @return array
127
     */
128
    public function getTos()
129
    {
130
        return $this->to;
131
    }
132
133
    /**
134
     * @param string $email
135
     * @param string|null $name
136
     * @return $this
137
     */
138
    public function addTo($email, $name = null)
139
    {
140
        $this->to[] = [
141
            'email' => $email,
142
            'name' => $name
143
        ];
144
        return $this;
145
    }
146
147
    /**
148
     * @return array
149
     */
150
    public function getCcs()
151
    {
152
        return $this->cc;
153
    }
154
155
    /**
156
     * @param string $email
157
     * @param string|null $name
158
     * @return $this
159
     */
160
    public function addCc($email, $name = null)
161
    {
162
        $this->cc[] = [
163
            'email' => $email,
164
            'name' => $name
165
        ];
166
        return $this;
167
    }
168
169
    /**
170
     * @return array
171
     */
172
    public function getBccs()
173
    {
174
        return $this->bcc;
175
    }
176
177
    /**
178
     * @param string $email
179
     * @param string|null $name
180
     * @return $this
181
     */
182
    public function addBcc($email, $name = null)
183
    {
184
        $this->bcc[] = [
185
            'email' => $email,
186
            'name' => $name
187
        ];
188
        return $this;
189
    }
190
191
    /**
192
     * @return array
193
     */
194
    public function getReplyTos()
195
    {
196
        return $this->replyTo;
197
    }
198
199
    /**
200
     * @return array
201
     */
202
    public function getReplyTo()
203
    {
204
        return count($this->replyTo) > 0 ? $this->replyTo[0] : [];
205
    }
206
207
    /**
208
     * @param string $email
209
     * @param string|null $name
210
     * @return $this
211
     */
212
    public function addReplyTo($email, $name = null)
213
    {
214
        $this->replyTo[] = [
215
            'email' => $email,
216
            'name' => $name
217
        ];
218
        return $this;
219
    }
220
221
    /**
222
     * @param string $email
223
     * @param string|null $name
224
     * @return $this
225
     */
226
    public function setReplyTo($email, $name = null)
227
    {
228
        $this->replyTo = [[
229
            'email' => $email,
230
            'name' => $name
231
        ]];
232
        return $this;
233
    }
234
235
    /**
236
     * @return array
237
     */
238
    public function getAttachements()
239
    {
240
        return $this->attachements;
241
    }
242
243
    /**
244
     * @param AttachmentInterface $attachment
245
     * @return $this
246
     */
247
    public function addAttachement(AttachmentInterface $attachment)
248
    {
249
        $this->attachements[] = $attachment;
250
        return $this;
251
    }
252
}
253