<?php

declare(strict_types=1);

namespace App\Framework\LiveComponents\Polling;

use App\Framework\Core\ValueObjects\ClassName;
use App\Framework\Core\ValueObjects\MethodName;
use App\Framework\Core\ValueObjects\Duration;
use App\Framework\LiveComponents\Attributes\Poll;

/**
 * Event dispatched after a poll has been executed successfully.
 */
final readonly class PollExecutedEvent
{
    public function __construct(
        public ClassName $className,
        public MethodName $methodName,
        public Poll $poll,
        public mixed $result,
        public Duration $executionTime
    ) {}

    public function getPollId(): string
    {
        return $this->className->getFullyQualified() . '::' . $this->methodName->toString();
    }
}
