1 | <?php |
||
15 | trait Replyable |
||
16 | { |
||
17 | |||
18 | private $swiftMessage; |
||
19 | |||
20 | /** |
||
21 | * Gmail optional parameters |
||
22 | * |
||
23 | * @var array |
||
24 | */ |
||
25 | private $parameters = []; |
||
26 | |||
27 | /** |
||
28 | * Text or html message to send |
||
29 | * |
||
30 | * @var string |
||
31 | */ |
||
32 | private $message; |
||
33 | |||
34 | /** |
||
35 | * Subject of the email |
||
36 | * |
||
37 | * @var string |
||
38 | */ |
||
39 | private $subject; |
||
40 | |||
41 | /** |
||
42 | * Sender's email |
||
43 | * |
||
44 | * @var string |
||
45 | */ |
||
46 | private $from; |
||
47 | |||
48 | /** |
||
49 | * Sender's name |
||
50 | * |
||
51 | * @var string |
||
52 | */ |
||
53 | private $nameFrom; |
||
54 | |||
55 | /** |
||
56 | * Email of the recipient |
||
57 | * |
||
58 | * @var string|array |
||
59 | */ |
||
60 | private $to; |
||
61 | |||
62 | /** |
||
63 | * Name of the recipient |
||
64 | * |
||
65 | * @var string |
||
66 | */ |
||
67 | private $nameTo; |
||
68 | |||
69 | /** |
||
70 | * Single email or array of email for a carbon copy |
||
71 | * |
||
72 | * @var array|string |
||
73 | */ |
||
74 | private $cc; |
||
75 | |||
76 | /** |
||
77 | * Name of the recipient |
||
78 | * |
||
79 | * @var string |
||
80 | */ |
||
81 | private $nameCc; |
||
82 | |||
83 | /** |
||
84 | * Single email or array of email for a blind carbon copy |
||
85 | * |
||
86 | * @var array|string |
||
87 | */ |
||
88 | private $bcc; |
||
89 | |||
90 | /** |
||
91 | * Name of the recipient |
||
92 | * |
||
93 | * @var string |
||
94 | */ |
||
95 | private $nameBcc; |
||
96 | |||
97 | /** |
||
98 | * List of attachments |
||
99 | * |
||
100 | * @var array |
||
101 | */ |
||
102 | private $attachments = []; |
||
103 | |||
104 | private $priority = 2; |
||
105 | |||
106 | public function __construct() |
||
110 | |||
111 | /** |
||
112 | * Receives the recipient's |
||
113 | * If multiple recipients will receive the message an array should be used. |
||
114 | * Example: array('[email protected]', '[email protected]' => 'A name') |
||
115 | * |
||
116 | * If $name is passed and the first parameter is a string, this name will be |
||
117 | * associated with the address. |
||
118 | * |
||
119 | * @param string|array $to |
||
120 | * |
||
121 | * @param string|null $name |
||
122 | * |
||
123 | * @return $this |
||
124 | */ |
||
125 | public function to( $to, $name = null ) |
||
132 | |||
133 | public function from( $from, $name = null ) |
||
140 | |||
141 | /** |
||
142 | * @param array|string $cc |
||
143 | * |
||
144 | * @param string|null $name |
||
145 | * |
||
146 | * @return $this |
||
147 | */ |
||
148 | public function cc( $cc, $name = null ) |
||
155 | |||
156 | /** |
||
157 | * @param array|string $bcc |
||
158 | * |
||
159 | * @param string|null $name |
||
160 | * |
||
161 | * @return $this |
||
162 | */ |
||
163 | public function bcc( $bcc, $name = null ) |
||
170 | |||
171 | /** |
||
172 | * @param string $subject |
||
173 | * |
||
174 | * @return $this |
||
175 | */ |
||
176 | public function subject( $subject ) |
||
182 | |||
183 | /** |
||
184 | * @param string $message |
||
185 | * |
||
186 | * @return $this |
||
187 | */ |
||
188 | public function message( $message ) |
||
194 | |||
195 | /** |
||
196 | * Attaches new file to the email from the Storage folder |
||
197 | * |
||
198 | * @param $path |
||
199 | * |
||
200 | * @return $this |
||
201 | * @throws \Exception |
||
202 | */ |
||
203 | public function attach( $path ) |
||
221 | |||
222 | /** |
||
223 | * The value is an integer where 1 is the highest priority and 5 is the lowest. |
||
224 | * |
||
225 | * @param int $priority |
||
226 | * |
||
227 | * @return $this |
||
228 | */ |
||
229 | public function priority( $priority ) |
||
235 | |||
236 | /** |
||
237 | * @param array $parameters |
||
238 | * |
||
239 | * @return $this |
||
240 | */ |
||
241 | public function optionalParameters( array $parameters ) |
||
247 | |||
248 | /** |
||
249 | * Reply to a specific email |
||
250 | * |
||
251 | * @return Mail |
||
252 | */ |
||
253 | public function reply() |
||
262 | |||
263 | /** |
||
264 | * Sends a new email |
||
265 | * |
||
266 | * @return Mail |
||
267 | */ |
||
268 | public function send() |
||
274 | |||
275 | /** |
||
276 | * Add a header to the email |
||
277 | * |
||
278 | * @param string $header |
||
279 | * @param string $value |
||
280 | */ |
||
281 | public function setHeader( $header, $value ) |
||
288 | |||
289 | /** |
||
290 | * @return Google_Service_Gmail_Message |
||
291 | */ |
||
292 | private function getMessageBody() |
||
293 | { |
||
294 | $body = new Google_Service_Gmail_Message(); |
||
295 | |||
296 | $this->swiftMessage |
||
297 | ->setSubject( $this->subject ) |
||
298 | ->setFrom( $this->from, $this->nameFrom ) |
||
299 | ->setTo( $this->to, $this->nameTo ) |
||
300 | ->setCc( $this->cc, $this->nameCc ) |
||
301 | ->setBcc( $this->bcc, $this->nameBcc ) |
||
302 | ->setBody( $this->message, 'text/html' ) |
||
303 | ->setPriority( $this->priority ); |
||
304 | |||
305 | foreach ( $this->attachments as $file ) { |
||
306 | $this->swiftMessage |
||
307 | ->attach( Swift_Attachment::fromPath( $file->path )->setFilename( $file->name ) ); |
||
308 | } |
||
309 | |||
310 | $body->setRaw( $this->base64_encode( $this->swiftMessage->toString() ) ); |
||
311 | |||
312 | return $body; |
||
313 | } |
||
314 | |||
315 | private function base64_encode( $data ) |
||
319 | |||
320 | private function emailList( $list, $name = null ) |
||
328 | |||
329 | private function convertEmailList( $emails, $name = null ) |
||
341 | |||
342 | private function setReplySubject() |
||
348 | |||
349 | private function setReplyThreat() |
||
358 | |||
359 | public abstract function getThreatId(); |
||
360 | } |
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.