Skip to content

Commit

Permalink
Update AllowedMimeTypes.php
Browse files Browse the repository at this point in the history
- Add getType static method from mime type
  • Loading branch information
ibnnajjaar committed Apr 17, 2024
1 parent 71d30b1 commit 8ccc32c
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/Media/AllowedMimeTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,20 @@ public static function getValidationRule(string $type, bool $as_array = false, ?

return $as_array ? $rules : implode('|', $rules);
}

/**
* Get the type from the mime type
* @param string $mime_type
* @return string|null
*/
public static function getType(string $mime_type): ?string
{
foreach (self::$allowed_mime_types as $type => $mime_types) {
if (in_array($mime_type, $mime_types)) {
return $type;
}
}

return null;
}
}

0 comments on commit 8ccc32c

Please sign in to comment.