Skip to content

Commit 8c09fd9

Browse files
committed
- Added getting all allowed mimetypes
1 parent 96f2897 commit 8c09fd9

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/Media/AllowedMimeTypes.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ public static function registerMimeTypeExtensions(array $extensions): void
297297
* @param string|array $type
298298
* @return array
299299
*/
300-
public static function getAllowedMimeTypes(string|array $type): array
300+
public static function getAllowedMimeTypes(string|array $type = ''): array
301301
{
302302
if (is_array($type)) {
303303
$mime_types = [];
@@ -321,7 +321,7 @@ public static function getAllowedMimeTypes(string|array $type): array
321321
* @param string $separator
322322
* @return string
323323
*/
324-
public static function getAllowedMimeTypesString(string|array $type, string $separator = ','): string
324+
public static function getAllowedMimeTypesString(string|array $type = '', string $separator = ','): string
325325
{
326326
return implode($separator, self::getAllowedMimeTypes($type));
327327
}
@@ -333,17 +333,22 @@ public static function getAllowedMimeTypesString(string|array $type, string $sep
333333
* @param string $type
334334
* @return boolean
335335
*/
336-
public static function isAllowedMimeType(string $mime_type, array|string $type): bool
336+
public static function isAllowedMimeType(string $mime_type, array|string $type = ''): bool
337337
{
338338
return in_array($mime_type, self::getAllowedMimeTypes($type));
339339
}
340340

341341
/**
342342
* Get the max size in kb for the given type
343343
*/
344-
public static function getMaxFileSize(string|array $types): int
344+
public static function getMaxFileSize(string|array $types = ''): int
345345
{
346346
$max_size = 0;
347+
348+
if (! $types) {
349+
$types = self::getAllowedTypes();
350+
}
351+
347352
$types = Arr::wrap($types);
348353

349354
foreach ($types as $type) {
@@ -373,7 +378,7 @@ public static function getMaxFileSize(string|array $types): int
373378
* @param bool $as_array
374379
* @return string|array
375380
*/
376-
public static function getValidationRule(string|array $type, bool $as_array = false, ?int $max_size = null): array|string
381+
public static function getValidationRule(string|array $type = '', bool $as_array = false, ?int $max_size = null): array|string
377382
{
378383
if (is_null($max_size)) {
379384
$max_size = self::getMaxFileSize($type);
@@ -426,7 +431,7 @@ public static function getFileSizeSetting(string $file_type): string
426431
* @param string|null $type
427432
* @return array
428433
*/
429-
public static function getAttachmentValidationRule(string|array $type = null): array
434+
public static function getAttachmentValidationRule(string|array|null $type = null): array
430435
{
431436
$rules = [
432437
'nullable',

0 commit comments

Comments
 (0)