Move enums into their own namespace

This commit is contained in:
Alex Cabal 2024-11-08 16:34:21 -06:00
parent c3c588cc1b
commit be5574eaec
45 changed files with 164 additions and 154 deletions

View file

@ -0,0 +1,8 @@
<?
namespace Enums;
enum ArtworkSortType: string{
case CreatedNewest = 'created-newest';
case ArtistAlpha = 'artist-alpha';
case CompletedNewest = 'completed-newest';
}

View file

@ -0,0 +1,8 @@
<?
namespace Enums;
enum ArtworkStatusType: string{
case Unverified = 'unverified';
case Declined = 'declined';
case Approved = 'approved';
}

View file

@ -0,0 +1,8 @@
<?
namespace Enums;
enum CollectionType: string{
case Series = 'series';
case Set = 'set';
case Unknown = 'unknown';
}

View file

@ -0,0 +1,16 @@
<?
namespace Enums;
enum EbookFormatType: string{
case Epub = 'epub';
case Azw3 = 'azw3';
case Kepub = 'kepub';
case AdvancedEpub = 'advanced-epub';
public function GetMimeType(): string{
return match($this){
self::Azw3 => 'application/x-mobi8-ebook',
default => 'application/epub+zip'
};
}
}

View file

@ -0,0 +1,9 @@
<?
namespace Enums;
enum EbookSortType: string{
case Newest = 'newest';
case AuthorAlpha = 'author-alpha';
case ReadingEase = 'reading-ease';
case Length = 'length';
}

View file

@ -0,0 +1,14 @@
<?
namespace Enums;
enum EbookSourceType: string{
case ProjectGutenberg = 'project_gutenberg';
case ProjectGutenbergAustralia = 'project_gutenberg_australia';
case ProjectGutenbergCanada = 'project_gutenberg_canada';
case InternetArchive = 'internet_archive';
case HathiTrust = 'hathi_trust';
case Wikisource = 'wikisource';
case GoogleBooks = 'google_books';
case FadedPage = 'faded_page';
case Other = 'other';
}

View file

@ -0,0 +1,48 @@
<?
namespace Enums;
use function Safe\mime_content_type;
enum ImageMimeType: string{
case JPG = 'image/jpeg';
case BMP = 'image/bmp';
case PNG = 'image/png';
case TIFF = 'image/tiff';
public function GetFileExtension(): string{
return match($this){
self::JPG => '.jpg',
self::BMP => '.bmp',
self::PNG => '.png',
self::TIFF => '.tif',
};
}
public static function FromFile(?string $path): ?ImageMimeType{
if($path === null || $path == ''){
return null;
}
$mimeType = mime_content_type($path);
$mimeType = match($mimeType){
'image/x-ms-bmp', 'image/x-bmp' => 'image/bmp',
default => $mimeType,
};
if(!$mimeType){
return null;
}
return ImageMimeType::tryFrom($mimeType);
}
/**
* @return array<string>
*/
public static function Values(): array{
return array_map(function(ImageMimeType $case){
return $case->value;
}, ImageMimeType::cases());
}
}

View file

@ -0,0 +1,6 @@
<?
namespace Enums;
enum PaymentProcessorType: string{
case FracturedAtlas = 'fractured_atlas';
}

7
lib/Enums/TagType.php Normal file
View file

@ -0,0 +1,7 @@
<?
namespace Enums;
enum TagType: string{
case Artwork = 'artwork';
case Ebook = 'ebook';
}

7
lib/Enums/ViewType.php Normal file
View file

@ -0,0 +1,7 @@
<?
namespace Enums;
enum ViewType: string{
case Grid = 'grid';
case List = 'list';
}