mirror of
https://github.com/standardebooks/web.git
synced 2025-07-12 17:42:29 -04:00
Move enums into their own namespace
This commit is contained in:
parent
c3c588cc1b
commit
be5574eaec
45 changed files with 164 additions and 154 deletions
8
lib/Enums/ArtworkSortType.php
Normal file
8
lib/Enums/ArtworkSortType.php
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?
|
||||
namespace Enums;
|
||||
|
||||
enum ArtworkSortType: string{
|
||||
case CreatedNewest = 'created-newest';
|
||||
case ArtistAlpha = 'artist-alpha';
|
||||
case CompletedNewest = 'completed-newest';
|
||||
}
|
8
lib/Enums/ArtworkStatusType.php
Normal file
8
lib/Enums/ArtworkStatusType.php
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?
|
||||
namespace Enums;
|
||||
|
||||
enum ArtworkStatusType: string{
|
||||
case Unverified = 'unverified';
|
||||
case Declined = 'declined';
|
||||
case Approved = 'approved';
|
||||
}
|
8
lib/Enums/CollectionType.php
Normal file
8
lib/Enums/CollectionType.php
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?
|
||||
namespace Enums;
|
||||
|
||||
enum CollectionType: string{
|
||||
case Series = 'series';
|
||||
case Set = 'set';
|
||||
case Unknown = 'unknown';
|
||||
}
|
16
lib/Enums/EbookFormatType.php
Normal file
16
lib/Enums/EbookFormatType.php
Normal 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'
|
||||
};
|
||||
}
|
||||
}
|
9
lib/Enums/EbookSortType.php
Normal file
9
lib/Enums/EbookSortType.php
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?
|
||||
namespace Enums;
|
||||
|
||||
enum EbookSortType: string{
|
||||
case Newest = 'newest';
|
||||
case AuthorAlpha = 'author-alpha';
|
||||
case ReadingEase = 'reading-ease';
|
||||
case Length = 'length';
|
||||
}
|
14
lib/Enums/EbookSourceType.php
Normal file
14
lib/Enums/EbookSourceType.php
Normal 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';
|
||||
}
|
48
lib/Enums/ImageMimeType.php
Normal file
48
lib/Enums/ImageMimeType.php
Normal 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());
|
||||
}
|
||||
}
|
6
lib/Enums/PaymentProcessorType.php
Normal file
6
lib/Enums/PaymentProcessorType.php
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?
|
||||
namespace Enums;
|
||||
|
||||
enum PaymentProcessorType: string{
|
||||
case FracturedAtlas = 'fractured_atlas';
|
||||
}
|
7
lib/Enums/TagType.php
Normal file
7
lib/Enums/TagType.php
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?
|
||||
namespace Enums;
|
||||
|
||||
enum TagType: string{
|
||||
case Artwork = 'artwork';
|
||||
case Ebook = 'ebook';
|
||||
}
|
7
lib/Enums/ViewType.php
Normal file
7
lib/Enums/ViewType.php
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?
|
||||
namespace Enums;
|
||||
|
||||
enum ViewType: string{
|
||||
case Grid = 'grid';
|
||||
case List = 'list';
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue