| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
namespace Webauthn\MetadataService\Statement; |
| 6 |
|
| 7 |
use Webauthn\Exception\MetadataStatementLoadingException; |
| 8 |
|
| 9 |
class DisplayPNGCharacteristicsDescriptor |
| 10 |
{ |
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
public function __construct( |
| 15 |
public readonly int $width, |
| 16 |
public readonly int $height, |
| 17 |
public readonly int $bitDepth, |
| 18 |
public readonly int $colorType, |
| 19 |
public readonly int $compression, |
| 20 |
public readonly int $filter, |
| 21 |
public readonly int $interlace, |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
public array $plte = [], |
| 26 |
) { |
| 27 |
$width >= 0 || throw MetadataStatementLoadingException::create('Invalid width'); |
| 28 |
$height >= 0 || throw MetadataStatementLoadingException::create('Invalid height'); |
| 29 |
($bitDepth >= 0 && $bitDepth <= 254) || throw MetadataStatementLoadingException::create('Invalid bit depth'); |
| 30 |
($colorType >= 0 && $colorType <= 254) || throw MetadataStatementLoadingException::create( |
| 31 |
'Invalid color type' |
| 32 |
); |
| 33 |
($compression >= 0 && $compression <= 254) || throw MetadataStatementLoadingException::create( |
| 34 |
'Invalid compression' |
| 35 |
); |
| 36 |
($filter >= 0 && $filter <= 254) || throw MetadataStatementLoadingException::create('Invalid filter'); |
| 37 |
($interlace >= 0 && $interlace <= 254) || throw MetadataStatementLoadingException::create( |
| 38 |
'Invalid interlace' |
| 39 |
); |
| 40 |
} |
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
public static function create( |
| 46 |
int $width, |
| 47 |
int $height, |
| 48 |
int $bitDepth, |
| 49 |
int $colorType, |
| 50 |
int $compression, |
| 51 |
int $filter, |
| 52 |
int $interlace, |
| 53 |
array $plte = [] |
| 54 |
): self { |
| 55 |
return new self($width, $height, $bitDepth, $colorType, $compression, $filter, $interlace, $plte); |
| 56 |
} |
| 57 |
} |