From 1b3fc2c23c37f09f1092c28f111387476a964798 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Sat, 29 Jul 2023 19:03:46 +0200 Subject: [PATCH] Fixed PHPUnit exception --- src/Services/Misc/FAIconGenerator.php | 3 --- src/Twig/AttachmentExtension.php | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/Services/Misc/FAIconGenerator.php b/src/Services/Misc/FAIconGenerator.php index 997e9f39..18db1fad 100644 --- a/src/Services/Misc/FAIconGenerator.php +++ b/src/Services/Misc/FAIconGenerator.php @@ -56,9 +56,6 @@ class FAIconGenerator */ public function fileExtensionToFAType(string $extension): string { - if ('' === $extension) { - throw new InvalidArgumentException('You must specify an extension!'); - } //Normalize file extension $extension = strtolower($extension); foreach (self::EXT_MAPPING as $fa => $exts) { diff --git a/src/Twig/AttachmentExtension.php b/src/Twig/AttachmentExtension.php index fd93de9a..9f81abe6 100644 --- a/src/Twig/AttachmentExtension.php +++ b/src/Twig/AttachmentExtension.php @@ -39,8 +39,8 @@ final class AttachmentExtension extends AbstractExtension return [ /* Returns the URL to a thumbnail of the given attachment */ new TwigFunction('attachment_thumbnail', fn(Attachment $attachment, string $filter_name = 'thumbnail_sm'): ?string => $this->attachmentURLGenerator->getThumbnailURL($attachment, $filter_name)), - /* Returns the font awesome icon class which is representing the given file extension */ - new TwigFunction('ext_to_fa_icon', fn(string $extension): string => $this->FAIconGenerator->fileExtensionToFAType($extension)), + /* Returns the font awesome icon class which is representing the given file extension (We allow null here for attachments without extension) */ + new TwigFunction('ext_to_fa_icon', fn(?string $extension): string => $this->FAIconGenerator->fileExtensionToFAType($extension ?? '')), ]; } }