Skip to content

Commit 395970f

Browse files
committed
Update BodyStructurePart.php
1 parent a615ef9 commit 395970f

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

src/BodyStructurePart.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ protected static function parse(array $tokens, string $partNumber): static
5151
? MimeParameterParser::parse($tokens[2]->toKeyValuePairs())
5252
: [],
5353
id: static::tokenValueAt($tokens, 3),
54-
description: Str::decodeMimeHeader(static::tokenValueAt($tokens, 4) ?? ''),
54+
description: is_null($description = static::tokenValueAt($tokens, 4))
55+
? null
56+
: Str::decodeMimeHeader($description),
5557
encoding: static::tokenValueAt($tokens, 5),
5658
size: static::tokenIntValueAt($tokens, 6),
5759
lines: static::tokenIntValueAt($tokens, 7),
@@ -66,7 +68,9 @@ protected static function parse(array $tokens, string $partNumber): static
6668
*/
6769
protected static function tokenValueAt(array $tokens, int $index): ?string
6870
{
69-
$token = $tokens[$index] ?? null;
71+
if (is_null($token = $tokens[$index] ?? null)) {
72+
return null;
73+
}
7074

7175
if (! $token instanceof Token || $token instanceof Nil) {
7276
return null;
@@ -84,7 +88,7 @@ protected static function tokenIntValueAt(array $tokens, int $index): ?int
8488
{
8589
$value = static::tokenValueAt($tokens, $index);
8690

87-
return $value === null ? null : (int) $value;
91+
return is_null($value) ? null : (int) $value;
8892
}
8993

9094
/**

0 commit comments

Comments
 (0)