Skip to content

Commit 376cc0c

Browse files
fix
1 parent 001499a commit 376cc0c

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/BodyStructure.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ protected static function fromBodyStructure($structure)
3838

3939
return (object) [
4040
'type' => 0,
41-
'encoding' => self::$encodingNumber[$structure[5]] ?? 0,
41+
'encoding' => self::getEncoding($structure, 5),
4242
'ifsubtype' => 1,
4343
'subtype' => $structure[1],
4444
'ifdescription' => 0,
@@ -122,7 +122,7 @@ protected static function extractPart($item)
122122

123123
$part = (object) [
124124
'type' => $type,
125-
'encoding' => is_numeric($item[5]) ? (self::$encodingNumber[$item[5]] ?? 0) : 0,
125+
'encoding' => self::getEncoding($item, 5),
126126
'ifsubtype' => 1,
127127
'subtype' => $item[1],
128128
'ifdescription' => 0,
@@ -215,15 +215,17 @@ protected static function processSubPartAsMessage($item)
215215

216216
$part = (object) [
217217
'type' => 0,
218-
'encoding' => 0,
218+
'encoding' => self::getEncoding($itemPart, 5),
219219
'ifsubtype' => 1,
220220
'subtype' => 'PLAIN',
221221
'ifdescription' => 0,
222222
'ifid' => 0,
223-
'lines' => 1,
224-
'bytes' => 9,
223+
'lines' => intval($itemPart[7]),
224+
'bytes' => intval($itemPart[6]),
225225
'ifdisposition' => 0,
226+
'disposition' => [],
226227
'ifdparameters' => 0,
228+
'dparameters' => [],
227229
'ifparameters' => 1,
228230
'parameters' => $parameters
229231
];
@@ -285,4 +287,9 @@ protected static function extractParameters($attributes, $parameters)
285287

286288
return $parameters;
287289
}
290+
291+
protected static function getEncoding($item, $encodingIndex)
292+
{
293+
return isset($item[$encodingIndex]) ? (self::$encodingNumber[$item[$encodingIndex]] ?? 0) : 0;
294+
}
288295
}

0 commit comments

Comments
 (0)