Skip to content

Commit

Permalink
Convert Unit and Orientation to BackedEnum (#252)
Browse files Browse the repository at this point in the history
Co-authored-by: Орлов Илья <[email protected]>
  • Loading branch information
MrMeshok and Орлов Илья authored May 7, 2024
1 parent 4e8dbcc commit 2e848dc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
17 changes: 6 additions & 11 deletions src/Enums/Orientation.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
6 changes: 3 additions & 3 deletions src/Enums/Unit.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Spatie\Image\Enums;

enum Unit
enum Unit: string
{
case Pixel;
case Percent;
case Pixel = 'pixel';
case Percent = 'percent';
}

0 comments on commit 2e848dc

Please sign in to comment.