1
0
mirror of https://github.com/Chouchen/ShikiryuRSS.git synced 2025-09-10 02:24:33 +02:00

🚧 Continues tests, parser and starts builder

For #4
This commit is contained in:
2023-04-07 17:57:35 +02:00
parent fec8c122e3
commit 63d0b03b50
18 changed files with 494 additions and 234 deletions

View File

@@ -2,33 +2,68 @@
namespace Shikiryu\SRSS\Entity;
class Item implements SRSSElement
use Shikiryu\SRSS\Validator\HasValidator;
use Shikiryu\SRSS\Validator\Validator;
/**
* https://cyber.harvard.edu/rss/rss.html#hrelementsOfLtitemgt
*/
class Item extends HasValidator implements SRSSElement
{
public ?string $title;
public ?string $link;
public ?string $description;
public ?string $author;
public ?string $category;
public ?string $comments;
public ?string $enclosure;
public ?string $guid;
public ?string $pubDate;
public ?string $source;
/**
* @requiredOr description
* @nohtml
*/
public ?string $title = null;
/**
* @url
*/
public ?string $link = null;
/**
* @requiredOr title
*/
public ?string $description = null;
/**
* @email
*/
public ?string $author = null;
/*
* TODO can be multiple with attributes and all
*/
public ?string $category = null;
/**
* @url
*/
public ?string $comments = null;
/*
* TODO 1 attributes and 1 value
*/
public ?string $enclosure = null;
public ?string $guid = null;
/**
* @date
*/
public ?string $pubDate = null;
/*
* TODO 1 attributes and 1 value
*/
public ?string $source = null;
/**
* @var \Shikiryu\SRSS\Entity\Media\Content[]
* @contentMedia
*/
public array $medias = [];
public array $required = ['description'];
public function isValid(): bool
{
return count(array_filter($this->required, fn($field) => !empty($this->{$field}))) === 0;
return (new Validator())->isObjectValid($this);
}
public function toArray(): array
{
return get_object_vars($this);
$vars = get_object_vars($this);
unset($vars['validated']);
return $vars;
}
}