@@ -952,14 +952,15 @@ private static function getLocalConfigurationByPath(string $path)
952952 *
953953 * @param mixed $file The file array to filter
954954 * @param array $allowedCategories The allowed MIME type categories to filter by (e.g., ['audio'], ['video'] or ['image', 'application'])
955- * @param array|null $dlfMimeTypes Optional array of custom DLF mimetype keys to filter by. Default is null.
956- * Pass null to use all available custom DLF mimetype keys
957- * Pass array of keys to use only specific types - Accepted values: 'IIIF', 'IIP', 'ZOOMIFY', 'JPG'
955+ * @param null|bool|array $dlfMimeTypes Optional array of custom dlf mimetype keys to filter by. Default is null.
956+ * - null: use no custom dlf mimetypes
957+ * - true: use all custom dlf mimetypes
958+ * - array: use only specific types - Accepted values: 'IIIF', 'IIP', 'ZOOMIFY', 'JPG'
958959 * @param string $mimeTypeKey The key used to access the mimetype in the file array (default is 'mimetype')
959960 *
960961 * @return bool True if the file mimetype belongs to any of the allowed mimetypes or matches any custom dlf mimetypes, false otherwise
961962 */
962- public static function filterFilesByMimeType ($ file , array $ allowedCategories , ? array $ dlfMimeTypes = null , string $ mimeTypeKey = 'mimetype ' ): bool
963+ public static function filterFilesByMimeType ($ file , array $ allowedCategories , null | bool | array $ dlfMimeTypes = null , string $ mimeTypeKey = 'mimetype ' ): bool
963964 {
964965 if (empty ($ allowedCategories ) && empty ($ dlfMimeTypes )) {
965966 return false ;
@@ -988,9 +989,12 @@ function ($mimeType) use ($allowedCategories) {
988989 ];
989990
990991 // Apply filtering to the custom dlf MIME type array
991- $ filteredDlfMimeTypes = $ dlfMimeTypes === null
992- ? $ dlfMimeTypeArray
993- : array_intersect_key ($ dlfMimeTypeArray , array_flip ($ dlfMimeTypes ));
992+ $ filteredDlfMimeTypes = match (true ) {
993+ $ dlfMimeTypes === null => [],
994+ $ dlfMimeTypes === true => $ dlfMimeTypeArray ,
995+ is_array ($ dlfMimeTypes ) => array_intersect_key ($ dlfMimeTypeArray , array_flip ($ dlfMimeTypes )),
996+ default => []
997+ };
994998
995999 // Actual filtering to check if the file's MIME type is allowed
9961000 if (is_array ($ file ) && isset ($ file [$ mimeTypeKey ])) {
0 commit comments