Fixed PHPUnit exception

This commit is contained in:
Jan Böhmer 2023-07-29 19:03:46 +02:00
parent 8e96971b9c
commit 1b3fc2c23c
2 changed files with 2 additions and 5 deletions

View file

@ -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) {

View file

@ -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 ?? '')),
];
}
}