name; } public function lowercase(): string { return strtolower($this->name); } public static function from(int|string $value): self { return match (is_string($value) ? strtoupper($value) : $value) { 'DESC', 2 => self::DESC, 'ASC', 1 => self::ASC, default => throw new \InvalidArgumentException('Invalid order direction'), }; } public static function tryFrom(int|string $value): ?self { if (is_string($value) && is_numeric($value)) { $value = (int) $value; } try { return self::from($value); } catch (\InvalidArgumentException) { return null; } } }