<?php

declare(strict_types=1);

namespace App\Framework\Queue\Events;

use App\Framework\Core\ValueObjects\Timestamp;

final readonly class JobChainCompletedEvent
{
    public Timestamp $timestamp;

    public function __construct(
        public string $chainId,
        public string $name,
        public string $completedAt,
        ?Timestamp $timestamp = null
    ) {
        $this->timestamp = $timestamp ?? Timestamp::now();
    }

    public function getEventData(): array
    {
        return [
            'event_type' => 'job_chain_completed',
            'chain_id' => $this->chainId,
            'name' => $this->name,
            'completed_at' => $this->completedAt,
            'timestamp' => $this->timestamp->toFloat(),
        ];
    }
}
