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
|
|
|
/**
|
|
|
|
* @required
|
|
|
|
* @nohtml
|
|
|
|
*/
|
2023-04-07 17:57:35 +02:00
|
|
|
public string $title = '';
|
2023-04-07 00:35:20 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @required
|
|
|
|
* @url
|
|
|
|
*/
|
2023-04-07 17:57:35 +02:00
|
|
|
public string $link = '';
|
2023-04-07 00:35:20 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @required
|
|
|
|
*/
|
2023-04-07 17:57:35 +02:00
|
|
|
public string $description = '';
|
2023-04-06 00:38:26 +02:00
|
|
|
|
2023-04-07 00:35:20 +02:00
|
|
|
/**
|
|
|
|
* @lang
|
|
|
|
*/
|
|
|
|
public ?string $language = null;
|
|
|
|
/**
|
|
|
|
* @nohtml
|
|
|
|
*/
|
|
|
|
public ?string $copyright = null;
|
|
|
|
/**
|
|
|
|
* @nohtml
|
|
|
|
*/
|
|
|
|
public ?string $managingEditor = null;
|
|
|
|
/**
|
|
|
|
* @nohtml
|
|
|
|
*/
|
|
|
|
public ?string $webMaster = null;
|
|
|
|
/**
|
|
|
|
* @date
|
|
|
|
*/
|
|
|
|
public ?string $pubDate = null;
|
|
|
|
/**
|
|
|
|
* @date
|
|
|
|
*/
|
|
|
|
public ?string $lastBuildDate = null;
|
|
|
|
/**
|
2023-04-12 00:28:14 +02:00
|
|
|
* @var Category[]
|
2023-04-07 00:35:20 +02:00
|
|
|
*/
|
2023-04-12 00:28:14 +02:00
|
|
|
public ?array $category = null;
|
2023-04-07 00:35:20 +02:00
|
|
|
/**
|
|
|
|
* @nohtml
|
|
|
|
*/
|
|
|
|
public ?string $generator = null;
|
|
|
|
/**
|
|
|
|
* @url
|
|
|
|
*/
|
|
|
|
public ?string $docs = null;
|
|
|
|
/**
|
2023-04-12 00:28:14 +02:00
|
|
|
* @var Cloud|null
|
2023-04-07 00:35:20 +02:00
|
|
|
*/
|
2023-04-12 00:28:14 +02:00
|
|
|
public ?Cloud $cloud = null;
|
2023-04-07 00:35:20 +02:00
|
|
|
/**
|
|
|
|
* @int
|
|
|
|
*/
|
|
|
|
public ?string $ttl = null;
|
|
|
|
public ?Image $image = null;
|
|
|
|
public ?string $rating = null;
|
|
|
|
/**
|
|
|
|
* @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.
|
|
|
|
*/
|
|
|
|
public ?string $textInput = null;
|
|
|
|
/**
|
|
|
|
* @hour
|
|
|
|
*/
|
|
|
|
public ?string $skipHours = null;
|
|
|
|
/**
|
|
|
|
* @day
|
|
|
|
*/
|
|
|
|
public ?string $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
|
|
|
}
|