<?php

declare(strict_types=1);

namespace Drupal\ffmpeg_media\Event;

use Drupal\Component\EventDispatcher\Event;
use Drupal\ffmpeg_media\ValueObject\ProgressData;
use Drupal\media\MediaInterface;

/**
 * Event dispatched during video conversion with progress updates.
 */
final class ConversionProgressEvent extends Event {

  /**
   * Constructs a ConversionProgressEvent.
   *
   * @param \Drupal\media\MediaInterface $media
   *   The media entity being converted.
   * @param \Drupal\ffmpeg_media\ValueObject\ProgressData $progress
   *   Current progress data.
   */
  public function __construct(
    public readonly MediaInterface $media,
    public readonly ProgressData $progress,
  ) {}

  /**
   * Gets the media entity ID.
   *
   * @return int
   *   The media entity ID.
   */
  public function getMediaId(): int {
    return (int) $this->media->id();
  }

  /**
   * Gets the current progress percentage.
   *
   * @return int
   *   Progress percentage (0-100).
   */
  public function getPercent(): int {
    return $this->progress->percent;
  }

  /**
   * Gets the current step description.
   *
   * @return string|null
   *   Current step or NULL.
   */
  public function getCurrentStep(): ?string {
    return $this->progress->currentStep;
  }

}
