<?php

declare(strict_types=1);

namespace App\Framework\Queue\Exceptions;

use App\Framework\Exception\FrameworkException;
use App\Framework\Exception\ValidationErrorCode;

final class InvalidDeadLetterQueueNameException extends FrameworkException
{
    public static function tooShort(string $name, int $minLength): self
    {
        return self::create(
            ValidationErrorCode::BUSINESS_RULE_VIOLATION,
            "Dead letter queue name '{$name}' is too short. Minimum length is {$minLength} characters."
        )->withData([
            'name' => $name,
            'actual_length' => strlen($name),
            'min_length' => $minLength,
        ]);
    }

    public static function tooLong(string $name, int $maxLength): self
    {
        return self::create(
            ValidationErrorCode::BUSINESS_RULE_VIOLATION,
            "Dead letter queue name '{$name}' is too long. Maximum length is {$maxLength} characters."
        )->withData([
            'name' => $name,
            'actual_length' => strlen($name),
            'max_length' => $maxLength,
        ]);
    }

    public static function invalidFormat(string $name, string $pattern): self
    {
        return self::create(
            ValidationErrorCode::BUSINESS_RULE_VIOLATION,
            "Dead letter queue name '{$name}' contains invalid characters. Only alphanumeric characters, underscores, hyphens, and dots are allowed."
        )->withData([
            'name' => $name,
            'valid_pattern' => $pattern,
        ]);
    }
}
