From b95a0b2ec4efa82b451e4722ab45c1daecad6e90 Mon Sep 17 00:00:00 2001 From: Riddick Date: Fri, 18 Oct 2024 08:13:50 +0200 Subject: [PATCH] Rename MimeType to CommonMimeType (#95) --- src/kernel/http/firehub.Request.php | 15 ++++++++------- ...ub.MimeType.php => firehub.CommonMimeType.php} | 8 ++++---- 2 files changed, 12 insertions(+), 11 deletions(-) rename src/support/enums/http/{firehub.MimeType.php => firehub.CommonMimeType.php} (93%) diff --git a/src/kernel/http/firehub.Request.php b/src/kernel/http/firehub.Request.php index 837efc3ac..a27d963cf 100644 --- a/src/kernel/http/firehub.Request.php +++ b/src/kernel/http/firehub.Request.php @@ -22,7 +22,8 @@ Indexed, Associative }; use FireHub\Core\Support\Enums\ { - Language, Geo\Country, URL\Schema, HTTP\ContentEncoding, HTTP\Method, HTTP\MimeType, HTTP\Cache\Request as RequestCache + Language, Geo\Country, URL\Schema, HTTP\ContentEncoding, HTTP\Method, HTTP\CommonMimeType, HTTP\Cache\Request as + RequestCache }; use FireHub\Core\Support\LowLevel\Arr; use Exception; @@ -340,16 +341,16 @@ public function userAgent ():string|false { * @uses \FireHub\Core\Support\Str::from() To create string. * @uses \FireHub\Core\Support\Str::break() To split encodings. * @uses \FireHub\Core\Support\Str::trim() To strip whitespace. - * @uses \FireHub\Core\Support\Str::containTimes() To check how many times character (*) exists. + * @uses \FireHub\Core\Support\Str::containTimes() To check how much times character (*) exists. * @uses \FireHub\Core\Support\Str::startsWith() To check if the acceptance header starts with a given value. * @uses \FireHub\Core\Support\Str::carryUntil() To carry acceptance header until character (*). * @uses \FireHub\Core\Support\Str::string() To get raw string. - * @uses \FireHub\Core\Support\Enums\HTTP\MimeType::casesIf() To generate a list of cases on an enum based on + * @uses \FireHub\Core\Support\Enums\HTTP\CommonMimeType::casesIf() To generate a list of cases on an enum based on * callable. * @uses \FireHub\Core\Support\LowLevel\Arr::inArray() To check if the acceptance header exists in an 'encoding' column. * @uses \FireHub\Core\Support\LowLevel\Arr::column() To create an array with an 'encoding' column. * - * @return \FireHub\Core\Support\Collection\Type\Indexed|false Accept-list. + * @return \FireHub\Core\Support\Collection\Type\Indexed|false Accept-list. */ public function accept ():Indexed|false { @@ -374,10 +375,10 @@ public function accept ():Indexed|false { break; - case MimeType::tryFrom($values[0]): + case CommonMimeType::tryFrom($values[0]): $result[] = [ - 'type' => MimeType::from($values[0]), + 'type' => CommonMimeType::from($values[0]), 'weight' => (float)($values[1] ?? 1) ]; @@ -385,7 +386,7 @@ public function accept ():Indexed|false { case $value->containTimes('*') === 1: - $cases = MimeType::casesIf(fn($case) => Str::from($case->value)->startsWith( + $cases = CommonMimeType::casesIf(fn($case) => Str::from($case->value)->startsWith( Str::from($values[0])->carryUntil('*')->string() // @phpstan-ignore-line )); diff --git a/src/support/enums/http/firehub.MimeType.php b/src/support/enums/http/firehub.CommonMimeType.php similarity index 93% rename from src/support/enums/http/firehub.MimeType.php rename to src/support/enums/http/firehub.CommonMimeType.php index 66999c8fa..e344bb65b 100644 --- a/src/support/enums/http/firehub.MimeType.php +++ b/src/support/enums/http/firehub.CommonMimeType.php @@ -20,12 +20,12 @@ use FireHub\Core\Support\Str; /** - * ### HTTP content media type + * ### HTTP common content media type * @since 1.0.0 * * @link https://www.iana.org/assignments/media-types/media-types.xhtml For a complete list. */ -enum MimeType:string implements InitBackedEnum { +enum CommonMimeType:string implements InitBackedEnum { /** * ### FireHub initial concrete-backed enum trait @@ -156,7 +156,7 @@ enum MimeType:string implements InitBackedEnum { * ### Get case types * @since 1.0.0 * - * @uses \FireHub\Core\Support\Enums\HTTP\MimeType::casesIf() To generate a list of cases on an enum based on + * @uses \FireHub\Core\Support\Enums\HTTP\CommonMimeType::casesIf() To generate a list of cases on an enum based on * callable. * @uses \FireHub\Core\Support\Str::from() To create a string form type. * @uses \FireHub\Core\Support\Str::startsWith() To check if type starts with type argument. @@ -170,7 +170,7 @@ enum MimeType:string implements InitBackedEnum { */ public static function casesType (string $type):array { - return MimeType::casesIf(fn($case) => Str::from($case->value)->startsWith( + return CommonMimeType::casesIf(fn($case) => Str::from($case->value)->startsWith( Str::from($type)->string() // @phpstan-ignore-line ));