ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
IsMimeTypeOrExtension.php
Go to the documentation of this file.
1<?php
2
20
22
26trait IsMimeTypeOrExtension
27{
28 protected function isMimeTypeOrExtension(
29 Metadata $metadata,
30 string $extention,
31 array $mime_types
32 ): bool {
33 // is mime type
34 $mime_type = strtolower($metadata->getMimeType());
35 $mime_types = array_map('strtolower', $mime_types);
36 if (in_array($mime_type, $mime_types, true)) {
37 return true;
38 }
39 // is extension
40 return substr_compare(
41 $metadata->getFilename(),
42 $extention,
43 -strlen($extention),
44 null,
45 true
46 ) === 0;
47 }
48}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...