Skip to content

Commit 3ba7f3d

Browse files
committed
remove repetitive code for body add part in Mail writer
1 parent 0c11259 commit 3ba7f3d

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

src/Handler/Writer/Mail.php

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,7 @@ public function shutdown() : void
5454
$body = new MimeMessage();
5555
$body->addPart($mimePart);
5656

57-
foreach ($this->requestData['files_data'] as $key => $row) {
58-
if (\key($row) === 'name') {
59-
// single upload
60-
$body = $this->singleBodyAddPart($body, $row);
61-
continue;
62-
}
63-
64-
// collection upload
65-
$body = $this->collectionBodyAddPart($body, $row);
66-
}
67-
57+
$body = $this->bodyAddPart($body, $this->requestData['files_data']);
6858
$this->mail->setBody($body);
6959

7060
$headers = $this->mail->getHeaders();
@@ -100,15 +90,15 @@ private function singleBodyAddPart(MimeMessage $body, array $data) : MimeMessage
10090
return $body->addPart($mimePart);
10191
}
10292

103-
private function collectionBodyAddPart(MimeMessage $body, array $data) : MimeMessage
93+
private function bodyAddPart(MimeMessage $body, array $data) : MimeMessage
10494
{
10595
foreach ($data as $multiple => $upload) {
10696
if (\key($upload) === 'name') {
10797
$body = $this->singleBodyAddPart($body, $upload);
10898
continue;
10999
}
110100

111-
$body = $this->collectionBodyAddPart($body, $upload);
101+
$body = $this->bodyAddPart($body, $upload);
112102
}
113103

114104
return $body;

0 commit comments

Comments
 (0)