From 1dc1088933c906d4676056d53395d34ce0a68d01 Mon Sep 17 00:00:00 2001 From: Sam Light Date: Mon, 27 Jul 2026 22:28:18 +0100 Subject: changed to use sort direction --- src/Support/SortDirections.php | 44 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/Support/SortDirections.php (limited to 'src/Support') diff --git a/src/Support/SortDirections.php b/src/Support/SortDirections.php new file mode 100644 index 0000000..def0f53 --- /dev/null +++ b/src/Support/SortDirections.php @@ -0,0 +1,44 @@ + self::ASC, + SortDirection::Descending => self::DESC, + }; + } + + public static function tryFrom(SortDirection|string|null $value): ?SortDirection + { + if ($value instanceof SortDirection) { + return $value; + } + + return match ($value === null ? null : strtolower($value)) { + self::ASC => SortDirection::Ascending, + self::DESC => SortDirection::Descending, + default => null, + }; + } +} -- cgit v1.2.3