<?php

namespace App\User\Action\Command;

use OneToMany\RichBundle\Contract\CommandInterface;
use Symfony\Component\Form\FormInterface;

/** @implements CommandInterface<SaveUserMediaPreferencesCommand> */
class SaveUserMediaPreferencesCommand implements CommandInterface
{
    public function __construct(
        public string $resolution,
        public string $codec,
        public string $quality,
        public string $language,
        public string $provider,
    ) {}

    public static function fromUserMediaPreferencesForm(FormInterface $form): self
    {
        return new static(
            resolution: \implode(',', $form->get('resolution')->getData()),
            codec: \implode(',', $form->get('codec')->getData()),
            quality: \implode(',', $form->get('quality')->getData()),
            language: \implode(',', $form->get('language')->getData()),
            provider: \implode(',', $form->get('provider')->getData()),
        );
    }
}