<?php
declare(strict_types=1);

namespace WP_AUX\Entities\Embeds\VideoSource;

use WP_AUX\Entities\Embeds\VideoEmbedEntity;

class InternalVideoSourceEntity extends HtmlVideoSourceEntity
{
  public static bool $isIframe = false;

  public static function create(
    string|array $video,
    ?string $title = null
  ): static
  {
    $url = null;

    if (is_array($video)) {
      $file = $video['file'];
      $url = $file['url'];
      $title = $video['title'] ? $video['title'] : $file['title'];
    } else {
      // TODO add support for creating video source by attachment ID
    }

    $videoSource = (new static($url, $title))
      ->setId($file['ID'])
      ->setMimeType($file['mime_type'])
      ->setProperties($file);

    return $videoSource;
  }
}
