Download src/Voice/Application/CommandHandlers/UpdateVoiceCommandHandler.php from pnacorp/AIKEEDO: direct link, hf CLI and curl.
- Browser
- Download file 1.33 kB
-
https://huggingface.co/pnacorp/AIKEEDO/resolve/main/src/Voice/Application/CommandHandlers/UpdateVoiceCommandHandler.php
- Command line
-
hf download hf://pnacorp/AIKEEDO/src/Voice/Application/CommandHandlers/UpdateVoiceCommandHandler.php
-
curl -L -o UpdateVoiceCommandHandler.php https://huggingface.co/pnacorp/AIKEEDO/resolve/main/src/Voice/Application/CommandHandlers/UpdateVoiceCommandHandler.php
1.33 kB
| namespace Voice\Application\CommandHandlers; | |
| use Voice\Application\Commands\UpdateVoiceCommand; | |
| use Voice\Domain\Entities\VoiceEntity; | |
| use Voice\Domain\Exceptions\VoiceNotFoundException; | |
| use Voice\Domain\VoiceRepositoyInterface; | |
| class UpdateVoiceCommandHandler | |
| { | |
| public function __construct( | |
| private VoiceRepositoyInterface $repo | |
| ) { | |
| } | |
| /** | |
| * @throws VoiceNotFoundException | |
| */ | |
| public function handle(UpdateVoiceCommand $cmd): VoiceEntity | |
| { | |
| $voice = $cmd->voice instanceof VoiceEntity | |
| ? $cmd->voice : $this->repo->ofId($cmd->voice); | |
| if ($cmd->status) { | |
| $voice->setStatus($cmd->status); | |
| } | |
| if ($cmd->name) { | |
| $voice->setName($cmd->name); | |
| } | |
| if ($cmd->sampleUrl) { | |
| $voice->setSampleUrl($cmd->sampleUrl); | |
| } | |
| if ($cmd->tones) { | |
| $voice->setTones(...$cmd->tones); | |
| } | |
| if ($cmd->useCases) { | |
| $voice->setUseCases(...$cmd->useCases); | |
| } | |
| if ($cmd->gender !== false) { | |
| $voice->setGender($cmd->gender); | |
| } | |
| if ($cmd->accent) { | |
| $voice->setAccent($cmd->accent); | |
| } | |
| if ($cmd->age !== false) { | |
| $voice->setAge($cmd->age); | |
| } | |
| return $voice; | |
| } | |
| } | |