<?php

declare(strict_types=1);

namespace App\Framework\Retry\Events;

use App\Framework\Core\ValueObjects\Timestamp;
use App\Framework\Retry\RetryResult;

/**
 * Event für erfolgreiche Retry-Operationen
 */
final readonly class RetrySucceededEvent
{
    public function __construct(
        public RetryResult $result,
        public array $context,
        public Timestamp $timestamp
    ) {
    }

    public function wasRetriedOperation(): bool
    {
        return $this->result->totalAttempts > 1;
    }

    public function getAttemptCount(): int
    {
        return $this->result->totalAttempts;
    }

    public function getDurationMs(): int
    {
        return (int)$this->result->totalDuration->toMilliseconds();
    }

    public function getOperationType(): ?string
    {
        return $this->context['operation_type'] ?? null;
    }
}
