2023-04-05 14:44:57 +02:00
|
|
|
<?php
|
|
|
|
|
2023-04-06 00:38:26 +02:00
|
|
|
namespace Shikiryu\SRSS\Entity\Media;
|
2023-04-05 14:44:57 +02:00
|
|
|
|
2023-04-12 15:28:38 +02:00
|
|
|
use ReflectionException;
|
2023-04-07 17:57:35 +02:00
|
|
|
use Shikiryu\SRSS\Entity\SRSSElement;
|
|
|
|
use Shikiryu\SRSS\Validator\HasValidator;
|
|
|
|
use Shikiryu\SRSS\Validator\Validator;
|
2023-04-05 14:44:57 +02:00
|
|
|
|
2023-04-07 17:57:35 +02:00
|
|
|
class Content extends HasValidator implements SRSSElement
|
2023-04-05 14:44:57 +02:00
|
|
|
{
|
|
|
|
/**
|
2023-04-17 14:28:01 +02:00
|
|
|
* @validate url
|
|
|
|
* @format url
|
2023-04-05 14:44:57 +02:00
|
|
|
*/
|
2023-04-17 14:28:01 +02:00
|
|
|
protected ?string $url = null;
|
2023-04-05 14:44:57 +02:00
|
|
|
/**
|
2023-04-17 14:28:01 +02:00
|
|
|
* @validate int
|
|
|
|
* @format int
|
2023-04-05 14:44:57 +02:00
|
|
|
*/
|
2023-04-17 14:28:01 +02:00
|
|
|
protected ?int $filesize = null;
|
2023-04-05 14:44:57 +02:00
|
|
|
/**
|
2023-04-17 14:28:01 +02:00
|
|
|
* @validate mediaType
|
2023-04-05 14:44:57 +02:00
|
|
|
*/
|
2023-04-17 14:28:01 +02:00
|
|
|
protected ?string $type = null;
|
2023-04-05 14:44:57 +02:00
|
|
|
/**
|
2023-04-17 14:28:01 +02:00
|
|
|
* @validate mediaMedium
|
|
|
|
* @format mediaMedium
|
2023-04-05 14:44:57 +02:00
|
|
|
*/
|
2023-04-17 14:28:01 +02:00
|
|
|
protected ?string $medium = null;
|
2023-04-05 14:44:57 +02:00
|
|
|
/**
|
2023-04-17 14:28:01 +02:00
|
|
|
* @validate bool
|
|
|
|
* @format bool
|
2023-04-05 14:44:57 +02:00
|
|
|
*/
|
2023-04-17 14:28:01 +02:00
|
|
|
protected ?bool $isDefault = null;
|
2023-04-07 17:57:35 +02:00
|
|
|
/**
|
2023-04-17 14:28:01 +02:00
|
|
|
* @validate mediaExpression
|
|
|
|
* @format mediaExpression
|
2023-04-07 17:57:35 +02:00
|
|
|
*/
|
2023-04-17 14:28:01 +02:00
|
|
|
protected ?string $expression = null;
|
2023-04-07 17:57:35 +02:00
|
|
|
/**
|
2023-04-17 14:28:01 +02:00
|
|
|
* @validate int
|
|
|
|
* @format int
|
2023-04-07 17:57:35 +02:00
|
|
|
*/
|
2023-04-17 14:28:01 +02:00
|
|
|
protected ?int $bitrate = null;
|
2023-04-07 17:57:35 +02:00
|
|
|
/**
|
2023-04-17 14:28:01 +02:00
|
|
|
* @validate int
|
|
|
|
* @format int
|
2023-04-07 17:57:35 +02:00
|
|
|
*/
|
2023-04-17 14:28:01 +02:00
|
|
|
protected ?int $framerate = null;
|
2023-04-07 17:57:35 +02:00
|
|
|
/**
|
2023-04-17 14:28:01 +02:00
|
|
|
* @validate float
|
|
|
|
* @format float
|
2023-04-07 17:57:35 +02:00
|
|
|
*/
|
2023-04-17 14:28:01 +02:00
|
|
|
protected ?float $samplerate = null;
|
2023-04-07 17:57:35 +02:00
|
|
|
/**
|
2023-04-17 14:28:01 +02:00
|
|
|
* @validate int
|
|
|
|
* @format int
|
2023-04-07 17:57:35 +02:00
|
|
|
*/
|
2023-04-17 14:28:01 +02:00
|
|
|
protected ?int $channels = null;
|
2023-04-07 17:57:35 +02:00
|
|
|
/**
|
2023-04-17 14:28:01 +02:00
|
|
|
* @validate int
|
|
|
|
* @format int
|
2023-04-07 17:57:35 +02:00
|
|
|
*/
|
2023-04-17 14:28:01 +02:00
|
|
|
protected ?int $duration = null;
|
2023-04-07 17:57:35 +02:00
|
|
|
/**
|
2023-04-17 14:28:01 +02:00
|
|
|
* @validate int
|
|
|
|
* @format int
|
2023-04-07 17:57:35 +02:00
|
|
|
*/
|
2023-04-17 14:28:01 +02:00
|
|
|
protected ?int $height = null;
|
2023-04-07 17:57:35 +02:00
|
|
|
/**
|
2023-04-17 14:28:01 +02:00
|
|
|
* @validate int
|
|
|
|
* @format int
|
2023-04-07 17:57:35 +02:00
|
|
|
*/
|
2023-04-17 14:28:01 +02:00
|
|
|
protected ?int $width = null;
|
2023-04-07 17:57:35 +02:00
|
|
|
/**
|
2023-04-17 14:28:01 +02:00
|
|
|
* @validate lang
|
2023-04-07 17:57:35 +02:00
|
|
|
*/
|
2023-04-17 14:28:01 +02:00
|
|
|
protected ?string $lang = null;
|
2023-04-06 00:38:26 +02:00
|
|
|
|
2023-04-07 17:57:35 +02:00
|
|
|
public function isValid(): bool
|
|
|
|
{
|
2023-04-11 23:49:03 +02:00
|
|
|
try {
|
|
|
|
return (new Validator())->isObjectValid($this);
|
2023-04-12 15:28:38 +02:00
|
|
|
} catch (ReflectionException) {
|
2023-04-11 23:49:03 +02:00
|
|
|
return false;
|
|
|
|
}
|
2023-04-07 17:57:35 +02:00
|
|
|
}
|
2023-04-06 00:38:26 +02:00
|
|
|
|
2023-04-07 17:57:35 +02:00
|
|
|
public function toArray(): array
|
|
|
|
{
|
|
|
|
return get_object_vars($this);
|
2023-04-05 14:44:57 +02:00
|
|
|
}
|
|
|
|
}
|