mirror of
https://github.com/Chouchen/ShikiryuRSS.git
synced 2026-11-24 01:01:18 +01:00
1 parent
4783124a1d
commit
bc0e818bbc
11 files changed
+438
-337
No files matched your search
+17
-1
@@ -4,7 +4,7 @@ namespace Shikiryu\SRSS\Entity;
|
||||
|
||||
use Shikiryu\SRSS\Entity\Channel\Image;
|
||||
|
||||
class Channel
|
||||
class Channel implements SRSSElement
|
||||
{
|
||||
public string $title;
|
||||
public string $link;
|
||||
@@ -28,4 +28,20 @@ class Channel
|
||||
public ?string $skipDays;
|
||||
|
||||
public array $required = ['title', 'link', 'description'];
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isValid(): bool
|
||||
{
|
||||
return count(array_filter($this->required, fn($field) => !empty($this->{$field}))) === 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
return get_object_vars($this);
|
||||
}
|
||||
}
|
||||
+16
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Shikiryu\SRSS\Entity;
|
||||
|
||||
class Item
|
||||
class Item implements SRSSElement
|
||||
{
|
||||
public ?string $title;
|
||||
public ?string $link;
|
||||
@@ -15,5 +15,20 @@ class Item
|
||||
public ?string $pubDate;
|
||||
public ?string $source;
|
||||
|
||||
/**
|
||||
* @var \Shikiryu\SRSS\Entity\Media\Content[]
|
||||
*/
|
||||
public array $medias = [];
|
||||
|
||||
public array $required = ['description'];
|
||||
|
||||
public function isValid(): bool
|
||||
{
|
||||
return count(array_filter($this->required, fn($field) => !empty($this->{$field}))) === 0;
|
||||
}
|
||||
|
||||
public function toArray(): array
|
||||
{
|
||||
return get_object_vars($this);
|
||||
}
|
||||
}
|
||||
@@ -58,7 +58,6 @@ class Content extends DomDocument
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* main getter for properties
|
||||
*
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Shikiryu\SRSS\Entity;
|
||||
|
||||
interface SRSSElement
|
||||
{
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isValid(): bool;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function toArray(): array;
|
||||
}
|
||||
Reference in new issue
Block a user