f39ad1804d
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
33 lines
926 B
PHP
33 lines
926 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace KTXF\Preview;
|
|
|
|
use InvalidArgumentException;
|
|
|
|
final readonly class PreviewRequest
|
|
{
|
|
public string $preferredMimeType;
|
|
|
|
public function __construct(
|
|
public int $maxWidth,
|
|
public int $maxHeight,
|
|
string $preferredMimeType,
|
|
public int $quality,
|
|
public int $maxSourceSize = 26214400,
|
|
) {
|
|
if ($this->maxWidth < 1 || $this->maxHeight < 1) {
|
|
throw new InvalidArgumentException('Preview dimensions must be positive');
|
|
}
|
|
if ($this->quality < 1 || $this->quality > 100) {
|
|
throw new InvalidArgumentException('Preview quality must be between 1 and 100');
|
|
}
|
|
if ($this->maxSourceSize < 1) {
|
|
throw new InvalidArgumentException('Preview maximum source size must be positive');
|
|
}
|
|
$this->preferredMimeType = MimeType::normalize($preferredMimeType);
|
|
}
|
|
|
|
}
|