<?php

namespace App\Library\Action\Input;

use App\Library\Action\Command\LibrarySearchCommand;
use OneToMany\RichBundle\Attribute\SourceQuery;
use OneToMany\RichBundle\Contract\CommandInterface;
use OneToMany\RichBundle\Contract\InputInterface;

/**
 * @implements InputInterface<LibrarySearchInput, LibrarySearchCommand>
 */
class LibrarySearchInput implements InputInterface
{
    public function __construct(
        #[SourceQuery('term', nullify: true)]
        private ?string $term = null,
        #[SourceQuery('title', nullify: true)]
        private ?string $title = null,
        #[SourceQuery('imdbId', nullify: true)]
        private ?string $imdbId = null,
        #[SourceQuery('season', nullify: true)]
        private ?string $season = null,
        #[SourceQuery('episode', nullify: true)]
        private ?string $episode = null,
    ) {}

    public function toCommand(): CommandInterface
    {
        return new LibrarySearchCommand(
            term: $this->term,
            title: $this->title,
            imdbId: $this->imdbId,
            season: $this->season,
            episode: $this->episode,
        );
    }
}
