<?php

namespace App\Exceptions;

use Exception;

class SlugScopedException extends Exception
{
    public function __construct(
        public readonly string $errorCode,
        string $message,
        public readonly array $conflict = [],
        public readonly int $httpStatus = 409,
        public readonly bool $requiresConfirmation = true,
    ) {
        parent::__construct($message);
    }

    public static function restorable(string $message, array $conflict): self
    {
        return new self('slug_restorable', $message, $conflict, 409, true);
    }

    public static function liveConflict(string $message, array $conflict): self
    {
        return new self('slug_conflict_live', $message, $conflict, 409, true);
    }

    public static function taken(string $message, array $conflict = []): self
    {
        return new self('slug_taken', $message, $conflict, 422, false);
    }
}
