mirror of
https://github.com/Chouchen/ShikiryuRSS.git
synced 2025-09-05 13:04:32 +02:00
🚧 Add complex types from docs
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
namespace Shikiryu\SRSS\Entity;
|
||||
|
||||
use ReflectionException;
|
||||
use Shikiryu\SRSS\Entity\Channel\Category;
|
||||
use Shikiryu\SRSS\Entity\Channel\Cloud;
|
||||
use Shikiryu\SRSS\Entity\Channel\Image;
|
||||
use Shikiryu\SRSS\Validator\HasValidator;
|
||||
use Shikiryu\SRSS\Validator\Validator;
|
||||
@@ -54,9 +56,9 @@ class Channel extends HasValidator implements SRSSElement
|
||||
*/
|
||||
public ?string $lastBuildDate = null;
|
||||
/**
|
||||
* TODO should be an array
|
||||
* @var Category[]
|
||||
*/
|
||||
public ?string $category = null;
|
||||
public ?array $category = null;
|
||||
/**
|
||||
* @nohtml
|
||||
*/
|
||||
@@ -66,10 +68,9 @@ class Channel extends HasValidator implements SRSSElement
|
||||
*/
|
||||
public ?string $docs = null;
|
||||
/**
|
||||
* @var string|null
|
||||
* TODO validator
|
||||
* @var Cloud|null
|
||||
*/
|
||||
public ?string $cloud = null;
|
||||
public ?Cloud $cloud = null;
|
||||
/**
|
||||
* @int
|
||||
*/
|
||||
|
33
src/Entity/Channel/Category.php
Normal file
33
src/Entity/Channel/Category.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Shikiryu\SRSS\Entity\Channel;
|
||||
|
||||
use Shikiryu\SRSS\Entity\SRSSElement;
|
||||
use Shikiryu\SRSS\Validator\HasValidator;
|
||||
use Shikiryu\SRSS\Validator\Validator;
|
||||
|
||||
class Category extends HasValidator implements SRSSElement
|
||||
{
|
||||
/**
|
||||
* @string
|
||||
*/
|
||||
public string $domain;
|
||||
/**
|
||||
* @string
|
||||
*/
|
||||
public string $value;
|
||||
|
||||
public function isValid(): bool
|
||||
{
|
||||
try {
|
||||
return (new Validator())->isObjectValid($this);
|
||||
} catch (\ReflectionException $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function toArray(): array
|
||||
{
|
||||
return get_object_vars($this);
|
||||
}
|
||||
}
|
47
src/Entity/Channel/Cloud.php
Normal file
47
src/Entity/Channel/Cloud.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace Shikiryu\SRSS\Entity\Channel;
|
||||
|
||||
use Shikiryu\SRSS\Entity\SRSSElement;
|
||||
use Shikiryu\SRSS\Validator\HasValidator;
|
||||
use Shikiryu\SRSS\Validator\Validator;
|
||||
|
||||
class Cloud extends HasValidator implements SRSSElement
|
||||
{
|
||||
/**
|
||||
* @string
|
||||
*/
|
||||
public string $domain;
|
||||
/**
|
||||
* @int
|
||||
*/
|
||||
public int $port;
|
||||
/**
|
||||
* @string
|
||||
*/
|
||||
public string $path;
|
||||
/**
|
||||
* @string
|
||||
*/
|
||||
public string $registerProcedure;
|
||||
/**
|
||||
* @string
|
||||
*/
|
||||
public string $protocol;
|
||||
|
||||
//<cloud domain="rpc.sys.com" port="80" path="/RPC2" registerProcedure="myCloud.rssPleaseNotify" protocol="xml-rpc" />
|
||||
|
||||
public function isValid(): bool
|
||||
{
|
||||
try {
|
||||
return (new Validator())->isObjectValid($this);
|
||||
} catch (\ReflectionException $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function toArray(): array
|
||||
{
|
||||
return get_object_vars($this);
|
||||
}
|
||||
}
|
@@ -2,6 +2,9 @@
|
||||
|
||||
namespace Shikiryu\SRSS\Entity;
|
||||
|
||||
use Shikiryu\SRSS\Entity\Item\Category;
|
||||
use Shikiryu\SRSS\Entity\Item\Enclosure;
|
||||
use Shikiryu\SRSS\Entity\Item\Source;
|
||||
use Shikiryu\SRSS\Entity\Media\Content;
|
||||
use Shikiryu\SRSS\Validator\HasValidator;
|
||||
use Shikiryu\SRSS\Validator\Validator;
|
||||
@@ -28,27 +31,28 @@ class Item extends HasValidator implements SRSSElement
|
||||
* @email
|
||||
*/
|
||||
public ?string $author = null;
|
||||
/*
|
||||
* TODO can be multiple with attributes and all
|
||||
/**
|
||||
* @var Category[]
|
||||
*/
|
||||
public ?string $category = null;
|
||||
public ?array $category = null;
|
||||
/**
|
||||
* @url
|
||||
*/
|
||||
public ?string $comments = null;
|
||||
/*
|
||||
* TODO 1 attributes and 1 value
|
||||
/**
|
||||
* @var Enclosure|null
|
||||
*/
|
||||
public ?string $enclosure = null;
|
||||
public ?Enclosure $enclosure = null;
|
||||
public ?string $guid = null;
|
||||
/**
|
||||
* @date
|
||||
*/
|
||||
public ?string $pubDate = null;
|
||||
/*
|
||||
* TODO 1 attributes and 1 value
|
||||
|
||||
/**
|
||||
* @var Source|null
|
||||
*/
|
||||
public ?string $source = null;
|
||||
public ?Source $source = null;
|
||||
|
||||
/**
|
||||
* @var Content[]
|
||||
|
33
src/Entity/Item/Category.php
Normal file
33
src/Entity/Item/Category.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Shikiryu\SRSS\Entity\Item;
|
||||
|
||||
use Shikiryu\SRSS\Entity\SRSSElement;
|
||||
use Shikiryu\SRSS\Validator\HasValidator;
|
||||
use Shikiryu\SRSS\Validator\Validator;
|
||||
|
||||
class Category extends HasValidator implements SRSSElement
|
||||
{
|
||||
/**
|
||||
* @string
|
||||
*/
|
||||
public string $domain;
|
||||
/**
|
||||
* @string
|
||||
*/
|
||||
public string $value;
|
||||
|
||||
public function isValid(): bool
|
||||
{
|
||||
try {
|
||||
return (new Validator())->isObjectValid($this);
|
||||
} catch (\ReflectionException $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function toArray(): array
|
||||
{
|
||||
return get_object_vars($this);
|
||||
}
|
||||
}
|
39
src/Entity/Item/Enclosure.php
Normal file
39
src/Entity/Item/Enclosure.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace Shikiryu\SRSS\Entity\Item;
|
||||
|
||||
use Shikiryu\SRSS\Entity\SRSSElement;
|
||||
use Shikiryu\SRSS\Validator\HasValidator;
|
||||
use Shikiryu\SRSS\Validator\Validator;
|
||||
|
||||
class Enclosure extends HasValidator implements SRSSElement
|
||||
{
|
||||
/**
|
||||
* @url
|
||||
*/
|
||||
public string $url;
|
||||
|
||||
/**
|
||||
* @int
|
||||
*/
|
||||
public int $length;
|
||||
|
||||
/**
|
||||
* @mediaType
|
||||
*/
|
||||
public string $type;
|
||||
|
||||
public function isValid(): bool
|
||||
{
|
||||
try {
|
||||
return (new Validator())->isObjectValid($this);
|
||||
} catch (\ReflectionException $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function toArray(): array
|
||||
{
|
||||
return get_object_vars($this);
|
||||
}
|
||||
}
|
34
src/Entity/Item/Source.php
Normal file
34
src/Entity/Item/Source.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace Shikiryu\SRSS\Entity\Item;
|
||||
|
||||
use Shikiryu\SRSS\Entity\SRSSElement;
|
||||
use Shikiryu\SRSS\Validator\HasValidator;
|
||||
use Shikiryu\SRSS\Validator\Validator;
|
||||
|
||||
class Source extends HasValidator implements SRSSElement
|
||||
{
|
||||
/**
|
||||
* @url
|
||||
*/
|
||||
public string $url;
|
||||
|
||||
/**
|
||||
* @nohtml
|
||||
*/
|
||||
public string $source;
|
||||
|
||||
public function isValid(): bool
|
||||
{
|
||||
try {
|
||||
return (new Validator())->isObjectValid($this);
|
||||
} catch (\ReflectionException $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function toArray(): array
|
||||
{
|
||||
return get_object_vars($this);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user