From 2e848dcf5c6780455d3d15a3e8f1dcec2571e06b Mon Sep 17 00:00:00 2001 From: MrMeshok <72924086+MrMeshok@users.noreply.github.com> Date: Tue, 7 May 2024 13:56:10 +0500 Subject: [PATCH] Convert Unit and Orientation to BackedEnum (#252) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Орлов Илья --- src/Enums/Orientation.php | 17 ++++++----------- src/Enums/Unit.php | 6 +++--- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/src/Enums/Orientation.php b/src/Enums/Orientation.php index 59956628..6ce64a8f 100644 --- a/src/Enums/Orientation.php +++ b/src/Enums/Orientation.php @@ -2,20 +2,15 @@ namespace Spatie\Image\Enums; -enum Orientation +enum Orientation: int { - case Rotate0; - case Rotate90; - case Rotate180; - case Rotate270; + case Rotate0 = 0; + case Rotate90 = 90; + case Rotate180 = 180; + case Rotate270 = 270; public function degrees(): int { - return match ($this) { - self::Rotate0 => 0, - self::Rotate90 => 90, - self::Rotate180 => 180, - self::Rotate270 => 270, - }; + return $this->value; } } diff --git a/src/Enums/Unit.php b/src/Enums/Unit.php index 61d83911..d0179137 100644 --- a/src/Enums/Unit.php +++ b/src/Enums/Unit.php @@ -2,8 +2,8 @@ namespace Spatie\Image\Enums; -enum Unit +enum Unit: string { - case Pixel; - case Percent; + case Pixel = 'pixel'; + case Percent = 'percent'; }