Skip to content

A self-hosted media server and file management system

chore: remove redundant functions from enums

aminnausinbdd4a0a8f379
diff --git a/app/Enums/HardwareType.php b/app/Enums/HardwareType.php
index 4afb4107..f126c4cb 100644
--- a/app/Enums/HardwareType.php
+++ b/app/Enums/HardwareType.php
@@ -11,8 +11,4 @@ enum HardwareType: int {
public function label(): string {
return strtolower($this->name);
}
-
- public static function fromLabel(string $label): ?self {
- return collect(self::cases())->first(fn ($case) => strtolower($case->name) === strtolower($label));
- }
}
diff --git a/app/Enums/ImageSource.php b/app/Enums/ImageSource.php
new file mode 100644
index 00000000..5d35c759
--- /dev/null
+++ b/app/Enums/ImageSource.php
@@ -0,0 +1,15 @@
+<?php
+
+namespace App\Enums;
+
+enum ImageSource: int {
+ case GENERATED = 0;
+ case UPLOADED = 1;
+ case API = 2;
+ case URL = 3; // external url, not downloaded
+ case DOWNLOADED = 4;
+
+ public function label(): string {
+ return strtolower($this->name);
+ }
+}
diff --git a/app/Enums/ImageType.php b/app/Enums/ImageType.php
new file mode 100644
index 00000000..c4b2ab6d
--- /dev/null
+++ b/app/Enums/ImageType.php
@@ -0,0 +1,13 @@
+<?php
+
+namespace App\Enums;
+
+enum ImageType: int {
+ case POSTER = 0;
+ case BANNER = 1;
+ case AVATAR = 2;
+
+ public function label(): string {
+ return strtolower($this->name);
+ }
+}
diff --git a/app/Enums/MediaType.php b/app/Enums/MediaType.php
index c31c0d38..6f8c2b42 100644
--- a/app/Enums/MediaType.php
+++ b/app/Enums/MediaType.php
@@ -14,35 +14,7 @@ enum MediaType: int {
return $this === self::AUDIO;
}
- /**
- * Check if a given value is a valid enum case.
- */
- public static function isValid(int $type): bool {
- foreach (self::cases() as $case) {
- if ($case->value == $type) {
- return true;
- }
- }
-
- return false;
- }
-
- public static function getValues(): array {
- return array_column(self::cases(), 'value');
- }
-
- public static function getLabel(MediaType $type): string {
- return match ($type) {
- self::VIDEO => 'video',
- self::AUDIO => 'audio',
- };
- }
-
- public static function fromLabel(string $label): ?self {
- return match (strtolower($label)) {
- 'video' => self::VIDEO,
- 'audio' => self::AUDIO,
- default => null,
- };
+ public function label(): string {
+ return strtolower($this->name);
}
}