Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions src/PhpImap/IncomingMailAttachment.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use const FILEINFO_MIME;
use const FILEINFO_NONE;
use finfo;
use Throwable;
use UnexpectedValueException;

/**
Expand Down Expand Up @@ -129,22 +128,16 @@ public function addDataPartInfo(DataPartInfo $dataInfo): void
* @param int $fileinfo_const Any predefined constant. See https://www.php.net/manual/en/fileinfo.constants.php
*
* @psalm-param fileinfoconst $fileinfo_const
*
* @return string|null
*/
public function getFileInfo($fileinfo_const = FILEINFO_NONE)
public function getFileInfo($fileinfo_const = FILEINFO_NONE): string
{
if ((FILEINFO_MIME == $fileinfo_const) and (false != $this->mimeType)) {
return $this->mimeType;
}

try {
$finfo = new finfo($fileinfo_const);
$finfo = new finfo($fileinfo_const);

return $finfo->buffer($this->getContents());
} catch (Throwable $ex) {
return null;
}
return $finfo->buffer($this->getContents());
}

/**
Expand Down