<?php
declare(strict_types=1);

namespace PpPhp\Core\Platform\Event\Retry\Policy;

use PpPhp\Core\Platform\Event\Retry\Contracts\RetryPolicyInterface;
use PpPhp\Core\Platform\Event\Retry\RetryContext;

final class FixedDelayRetryPolicy implements RetryPolicyInterface
{
    public function __construct(private readonly int $delaySeconds = 5) {}
    public function name(): string { return 'fixed-delay'; }
    public function shouldRetry(RetryContext $context): bool { return $context->attempt() < $context->maxAttempts(); }
    public function nextDelaySeconds(RetryContext $context): int { return max(0, $this->delaySeconds); }
}
