Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
francescobianco committed Jul 5, 2022
1 parent 001499a commit 376cc0c
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/BodyStructure.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected static function fromBodyStructure($structure)

return (object) [
'type' => 0,
'encoding' => self::$encodingNumber[$structure[5]] ?? 0,
'encoding' => self::getEncoding($structure, 5),
'ifsubtype' => 1,
'subtype' => $structure[1],
'ifdescription' => 0,
Expand Down Expand Up @@ -122,7 +122,7 @@ protected static function extractPart($item)

$part = (object) [
'type' => $type,
'encoding' => is_numeric($item[5]) ? (self::$encodingNumber[$item[5]] ?? 0) : 0,
'encoding' => self::getEncoding($item, 5),
'ifsubtype' => 1,
'subtype' => $item[1],
'ifdescription' => 0,
Expand Down Expand Up @@ -215,15 +215,17 @@ protected static function processSubPartAsMessage($item)

$part = (object) [
'type' => 0,
'encoding' => 0,
'encoding' => self::getEncoding($itemPart, 5),
'ifsubtype' => 1,
'subtype' => 'PLAIN',
'ifdescription' => 0,
'ifid' => 0,
'lines' => 1,
'bytes' => 9,
'lines' => intval($itemPart[7]),
'bytes' => intval($itemPart[6]),
'ifdisposition' => 0,
'disposition' => [],
'ifdparameters' => 0,
'dparameters' => [],
'ifparameters' => 1,
'parameters' => $parameters
];
Expand Down Expand Up @@ -285,4 +287,9 @@ protected static function extractParameters($attributes, $parameters)

return $parameters;
}

protected static function getEncoding($item, $encodingIndex)
{
return isset($item[$encodingIndex]) ? (self::$encodingNumber[$item[$encodingIndex]] ?? 0) : 0;
}
}

0 comments on commit 376cc0c

Please sign in to comment.