Open-source event management and ticket selling platform — perfect for concerts, conferences, and everything in between 🎟️ If you find this project helpful, please consider giving us a star ⭐️
PHP attendize-alternativedoor-managementevent-check-inevent-managementevent-registrationevent-ticketingeventbrite-alternativeeventslaravelopen-sourcephpreactself-hostedsell-ticketssell-tickets-onlineticket-sellingticketing-systemtickettailor-alternativetito-alternative
<?php
namespace HiEvents\Repository\Eloquent\Value;
use InvalidArgumentException;
class OrderAndDirection
{
public const DIRECTION_ASC = 'asc';
public const DIRECTION_DESC = 'desc';
public function __construct(
private readonly string $order,
private readonly string $direction = self::DIRECTION_ASC,
) {
$this->validate();
}
public function getOrder(): string
{
return $this->order;
}
public function getDirection(): string
{
return $this->direction;
}
private function validate(): void
{
if (! in_array($this->direction, ['asc', 'desc'])) {
throw new InvalidArgumentException(__('Invalid direction. Must be either asc or desc'));
}
}
}