<?php

declare(strict_types=1);

namespace App\Framework\Pagination\ValueObjects;

/**
 * Pagination direction for cursor-based pagination
 */
enum Direction: string
{
    case ASC = 'asc';
    case DESC = 'desc';

    /**
     * Check if direction is ascending
     */
    public function isAscending(): bool
    {
        return $this === self::ASC;
    }

    /**
     * Check if direction is descending
     */
    public function isDescending(): bool
    {
        return $this === self::DESC;
    }

    /**
     * Get opposite direction
     */
    public function opposite(): self
    {
        return match ($this) {
            self::ASC => self::DESC,
            self::DESC => self::ASC,
        };
    }

    /**
     * Get SQL ORDER BY clause value
     */
    public function toSql(): string
    {
        return strtoupper($this->value);
    }
}
