1
0
mirror of https://github.com/Chouchen/ShikiryuRSS.git synced 2024-05-18 18:01:31 +02:00
ShikiryuRSS/src/Entity/Channel.php

124 lines
2.6 KiB
PHP
Raw Normal View History

<?php
namespace Shikiryu\SRSS\Entity;
2023-04-07 00:35:20 +02:00
use ReflectionException;
use Shikiryu\SRSS\Entity\Channel\Category;
use Shikiryu\SRSS\Entity\Channel\Cloud;
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-07 00:35:20 +02:00
/**
* https://cyber.harvard.edu/rss/rss.html#requiredChannelElements
*/
class Channel extends HasValidator implements SRSSElement
{
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-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
/**
* @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
/**
* @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
*/
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
*/
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
{
return (new Validator())->isObjectValid($this);
2023-04-06 11:07:06 +02:00
}
/**
* @return array
*/
public function toArray(): array
{
$vars = get_object_vars($this);
unset($vars['validated']);
return $vars;
2023-04-06 11:07:06 +02:00
}
}