improve tests, validate frame file type

This commit is contained in:
Shaked Klein Orbach 2018-03-07 14:27:27 -06:00
commit fcd494f723
2 changed files with 39 additions and 13 deletions

View file

@ -37,6 +37,9 @@ class ExtractMultipleFramesFilter implements VideoFilterInterface
private $destinationFolder;
private $frameFileType = 'jpg';
/** @var array */
private static $supportedFrameFileTypes = ['jpg', 'jpeg', 'png'];
public function __construct($frameRate = self::FRAMERATE_EVERY_SEC, $destinationFolder = __DIR__, $priority = 0)
{
$this->priority = $priority;
@ -52,9 +55,16 @@ class ExtractMultipleFramesFilter implements VideoFilterInterface
/**
* @param string $frameFileType
* @throws \FFMpeg\Exception\InvalidArgumentException
* @return ExtractMultipleFramesFilter
*/
public function setFrameFileType($frameFileType) {
$this->frameFileType = $frameFileType;
if (in_array($frameFileType, self::$supportedFrameFileTypes)) {
$this->frameFileType = $frameFileType;
return $this;
}
throw new InvalidArgumentException('Invalid frame file type, use: ' . implode(',', self::$supportedFrameFileTypes));
}
/**