2023-04-06 00:38:26 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Shikiryu\SRSS\Entity;
|
|
|
|
|
2023-04-07 00:35:20 +02:00
|
|
|
use ReflectionException;
|
2023-04-12 00:28:14 +02:00
|
|
|
use Shikiryu\SRSS\Entity\Channel\Category;
|
|
|
|
use Shikiryu\SRSS\Entity\Channel\Cloud;
|
2023-04-06 00:38:26 +02:00
|
|
|
use Shikiryu\SRSS\Entity\Channel\Image;
|
2023-04-07 00:35:20 +02:00
|
|
|
use Shikiryu\SRSS\Validator\HasValidator;
|
|
|
|
use Shikiryu\SRSS\Validator\Validator;
|
2023-04-06 00:38:26 +02:00
|
|
|
|
2023-04-07 00:35:20 +02:00
|
|
|
/**
|
|
|
|
* https://cyber.harvard.edu/rss/rss.html#requiredChannelElements
|
|
|
|
*/
|
|
|
|
class Channel extends HasValidator implements SRSSElement
|
2023-04-06 00:38:26 +02:00
|
|
|
{
|
2023-04-07 00:35:20 +02:00
|
|
|
/**
|
2023-04-17 14:28:01 +02:00
|
|
|
* @validate required
|
|
|
|
* @format html
|
2023-04-07 00:35:20 +02:00
|
|
|
*/
|
2023-04-17 14:28:01 +02:00
|
|
|
protected string $title = '';
|
2023-04-07 00:35:20 +02:00
|
|
|
|
|
|
|
/**
|
2023-04-17 14:28:01 +02:00
|
|
|
* @validate required
|
|
|
|
* @validate url
|
|
|
|
* @format url
|
2023-04-07 00:35:20 +02:00
|
|
|
*/
|
2023-04-17 14:28:01 +02:00
|
|
|
protected string $link = '';
|
2023-04-07 00:35:20 +02:00
|
|
|
|
|
|
|
/**
|
2023-04-17 14:28:01 +02:00
|
|
|
* @validate required
|
|
|
|
* @format html
|
2023-04-07 00:35:20 +02:00
|
|
|
*/
|
2023-04-17 14:28:01 +02:00
|
|
|
protected string $description = '';
|
2023-04-06 00:38:26 +02:00
|
|
|
|
2023-04-07 00:35:20 +02:00
|
|
|
/**
|
2023-04-17 14:28:01 +02:00
|
|
|
* @validate lang
|
2023-04-07 00:35:20 +02:00
|
|
|
*/
|
2023-04-17 14:28:01 +02:00
|
|
|
protected ?string $language = null;
|
2023-04-07 00:35:20 +02:00
|
|
|
/**
|
2023-04-17 14:28:01 +02:00
|
|
|
* @validate nohtml
|
|
|
|
* @format nohtml
|
2023-04-07 00:35:20 +02:00
|
|
|
*/
|
2023-04-17 14:28:01 +02:00
|
|
|
protected ?string $copyright = null;
|
2023-04-07 00:35:20 +02:00
|
|
|
/**
|
2023-04-17 14:28:01 +02:00
|
|
|
* @validate nohtml
|
|
|
|
* @format nohtml
|
2023-04-07 00:35:20 +02:00
|
|
|
*/
|
2023-04-17 14:28:01 +02:00
|
|
|
protected ?string $managingEditor = null;
|
2023-04-07 00:35:20 +02:00
|
|
|
/**
|
2023-04-17 14:28:01 +02:00
|
|
|
* @validate nohtml
|
|
|
|
* @format nohtml
|
2023-04-07 00:35:20 +02:00
|
|
|
*/
|
2023-04-17 14:28:01 +02:00
|
|
|
protected ?string $webMaster = null;
|
2023-04-07 00:35:20 +02:00
|
|
|
/**
|
2023-04-17 14:28:01 +02:00
|
|
|
* @validate date
|
|
|
|
* @format date
|
2023-04-07 00:35:20 +02:00
|
|
|
*/
|
2023-04-17 14:28:01 +02:00
|
|
|
protected ?string $pubDate = null;
|
2023-04-07 00:35:20 +02:00
|
|
|
/**
|
2023-04-17 14:28:01 +02:00
|
|
|
* @validate date
|
|
|
|
* @format date
|
2023-04-07 00:35:20 +02:00
|
|
|
*/
|
2023-04-17 14:28:01 +02:00
|
|
|
protected ?string $lastBuildDate = null;
|
2023-04-07 00:35:20 +02:00
|
|
|
/**
|
2023-04-12 00:28:14 +02:00
|
|
|
* @var Category[]
|
2023-04-07 00:35:20 +02:00
|
|
|
*/
|
2023-04-17 14:28:01 +02:00
|
|
|
protected ?array $category = null;
|
2023-04-07 00:35:20 +02:00
|
|
|
/**
|
2023-04-17 14:28:01 +02:00
|
|
|
* @validate nohtml
|
|
|
|
* @format nohtml
|
2023-04-07 00:35:20 +02:00
|
|
|
*/
|
2023-04-17 14:28:01 +02:00
|
|
|
protected ?string $generator = null;
|
2023-04-07 00:35:20 +02:00
|
|
|
/**
|
2023-04-17 14:28:01 +02:00
|
|
|
* @validate url
|
|
|
|
* @format url
|
2023-04-07 00:35:20 +02:00
|
|
|
*/
|
2023-04-17 14:28:01 +02:00
|
|
|
protected ?string $docs = null;
|
2023-04-07 00:35:20 +02:00
|
|
|
/**
|
2023-04-12 00:28:14 +02:00
|
|
|
* @var Cloud|null
|
2023-04-07 00:35:20 +02:00
|
|
|
*/
|
2023-04-17 14:28:01 +02:00
|
|
|
protected ?Cloud $cloud = null;
|
2023-04-07 00:35:20 +02:00
|
|
|
/**
|
2023-04-17 14:28:01 +02:00
|
|
|
* @validate int
|
|
|
|
* @format int
|
2023-04-07 00:35:20 +02:00
|
|
|
*/
|
2023-04-17 14:28:01 +02:00
|
|
|
protected ?string $ttl = null;
|
|
|
|
protected ?Image $image = null;
|
|
|
|
protected ?string $rating = null;
|
2023-04-07 00:35:20 +02:00
|
|
|
/**
|
|
|
|
* @var string|null
|
|
|
|
* The purpose of the <textInput> element is something of a mystery. You can use it to specify a search engine box. Or to allow a reader to provide feedback. Most aggregators ignore it.
|
|
|
|
*/
|
2023-04-17 14:28:01 +02:00
|
|
|
protected ?string $textInput = null;
|
2023-04-07 00:35:20 +02:00
|
|
|
/**
|
2023-04-17 14:28:01 +02:00
|
|
|
* @validate hour
|
|
|
|
* @format hour
|
2023-04-07 00:35:20 +02:00
|
|
|
*/
|
2023-04-19 17:03:59 +02:00
|
|
|
protected ?array $skipHours = null;
|
2023-04-07 00:35:20 +02:00
|
|
|
/**
|
2023-04-17 14:28:01 +02:00
|
|
|
* @validate day
|
|
|
|
* @format day
|
2023-04-07 00:35:20 +02:00
|
|
|
*/
|
2023-04-19 17:03:59 +02:00
|
|
|
protected ?array $skipDays = null;
|
2023-04-06 11:07:06 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return bool
|
2023-04-07 00:35:20 +02:00
|
|
|
* @throws ReflectionException
|
2023-04-06 11:07:06 +02:00
|
|
|
*/
|
|
|
|
public function isValid(): bool
|
|
|
|
{
|
2023-04-07 17:57:35 +02:00
|
|
|
return (new Validator())->isObjectValid($this);
|
2023-04-06 11:07:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function toArray(): array
|
|
|
|
{
|
2023-04-07 17:57:35 +02:00
|
|
|
$vars = get_object_vars($this);
|
|
|
|
unset($vars['validated']);
|
|
|
|
return $vars;
|
2023-04-06 11:07:06 +02:00
|
|
|
}
|
2023-04-06 00:38:26 +02:00
|
|
|
}
|