feat(preview): add shared preview provider contracts
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace KTXF\Preview;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use KTXF\Resource\BinaryResource;
|
||||
|
||||
final readonly class PreviewResult
|
||||
{
|
||||
public function __construct(
|
||||
public BinaryResource $resource,
|
||||
public ?int $width = null,
|
||||
public ?int $height = null,
|
||||
) {
|
||||
MimeType::normalize($this->resource->mimeType());
|
||||
if ($this->width !== null && $this->width < 1) {
|
||||
throw new InvalidArgumentException('Preview result width must be positive');
|
||||
}
|
||||
if ($this->height !== null && $this->height < 1) {
|
||||
throw new InvalidArgumentException('Preview result height must be positive');
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user