mirror of
https://github.com/Chouchen/ShikiryuRSS.git
synced 2025-09-10 02:24:33 +02:00
@@ -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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user