Code Duplication    Length = 28-29 lines in 2 locations

transports/mail/drivers/Postmark.php 1 location

@@ 226-253 (lines=28) @@
223
     * @param   \Swift_Mime_Message $message    The MIME Message to process.
224
     * @param   array&              $payload    A reference to the payload structure.
225
     */
226
    protected function processAttachments(\Swift_Mime_Message $message, array &$payload)
227
    {
228
        if (!$children = $message->getChildren()) {
229
            return;
230
        }
231
232
        $payload['Attachments'] = [];
233
234
        foreach ($children as $attachment) {
235
236
            // Omit all entities that aren't actually attachments.
237
            if (!$attachment instanceof \Swift_Mime_Attachment) {
238
                continue;
239
            }
240
241
            $data = [
242
                'Name'        => $attachment->getFilename(),
243
                'Content'     => base64_encode($attachment->getBody()),
244
                'ContentType' => $attachment->getContentType()
245
            ];
246
247
            if ($attachment->getDisposition() !== 'attachment' && null !== $attachment->getId()) {
248
                $data['ContentID'] = 'cid:'.$attachment->getId();
249
            }
250
251
            $payload['Attachments'][] = $data;
252
        }
253
    }
254
}
255

transports/mail/drivers/Sendgrid.php 1 location

@@ 260-288 (lines=29) @@
257
     * @param   \Swift_Mime_Message $message    The MIME Message to process.
258
     * @param   array&              $payload    A reference to the payload structure.
259
     */
260
    protected function processAttachments(\Swift_Mime_Message $message, array &$payload)
261
    {
262
        if (!$children = $message->getChildren()) {
263
            return;
264
        }
265
266
        $payload['attachments'] = [];
267
268
        foreach ($children as $attachment) {
269
270
            // Omit all MIME Entities that aren't attachments.
271
            if (!$attachment instanceof \Swift_Mime_Attachment) {
272
                continue;
273
            }
274
275
            $data = [
276
                'filename'    => $attachment->getFilename(),
277
                'content'     => base64_encode($attachment->getBody()),
278
                'type'        => $attachment->getContentType(),
279
                'disposition' => $attachment->getDisposition(),
280
            ];
281
282
            if ($attachment->getDisposition() !== 'attachment' && null !== $cid = $attachment->getId()) {
283
                $data['content_id'] = 'cid:'.$cid;
284
            }
285
286
            $payload['attachments'][] = $data;
287
        }
288
    }
289
}
290