2023-04-12 00:28:14 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Shikiryu\SRSS\Entity\Item;
|
|
|
|
|
2023-04-12 15:28:38 +02:00
|
|
|
use ReflectionException;
|
2023-04-12 00:28:14 +02:00
|
|
|
use Shikiryu\SRSS\Entity\SRSSElement;
|
|
|
|
use Shikiryu\SRSS\Validator\HasValidator;
|
|
|
|
use Shikiryu\SRSS\Validator\Validator;
|
|
|
|
|
|
|
|
class Source extends HasValidator implements SRSSElement
|
|
|
|
{
|
|
|
|
/**
|
2023-04-17 14:28:01 +02:00
|
|
|
* @validate url
|
|
|
|
* @format url
|
2023-04-12 00:28:14 +02:00
|
|
|
*/
|
2023-04-17 14:28:01 +02:00
|
|
|
protected ?string $url = null;
|
2023-04-12 00:28:14 +02:00
|
|
|
|
|
|
|
/**
|
2023-04-17 14:28:01 +02:00
|
|
|
* @validate nohtml
|
|
|
|
* @format nohtml
|
2023-04-12 00:28:14 +02:00
|
|
|
*/
|
2023-04-17 14:28:01 +02:00
|
|
|
protected ?string $value = null;
|
2023-04-12 00:28:14 +02:00
|
|
|
|
|
|
|
public function isValid(): bool
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
return (new Validator())->isObjectValid($this);
|
2023-04-12 15:28:38 +02:00
|
|
|
} catch (ReflectionException) {
|
2023-04-12 00:28:14 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function toArray(): array
|
|
|
|
{
|
|
|
|
return get_object_vars($this);
|
|
|
|
}
|
|
|
|
}
|