Skip to content

Commit

Permalink
Rename MimeType to CommonMimeType (#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
danijelgalic committed Oct 18, 2024
1 parent 8841250 commit b95a0b2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
15 changes: 8 additions & 7 deletions src/kernel/http/firehub.Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<array{type: \FireHub\Core\Support\Enums\HTTP\MimeType|null, weight: float}>|false Accept-list.
* @return \FireHub\Core\Support\Collection\Type\Indexed<array{type: \FireHub\Core\Support\Enums\HTTP\CommonMimeType|null, weight: float}>|false Accept-list.
*/
public function accept ():Indexed|false {

Expand All @@ -374,18 +375,18 @@ 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)
];

break;

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
));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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
));

Expand Down

0 comments on commit b95a0b2

Please sign in to comment.