mirror of
https://github.com/Chouchen/ShikiryuRSS.git
synced 2024-11-22 07:48:51 +01:00
🚧 Add complex types from docs
This commit is contained in:
parent
cb6fff0dae
commit
cc7a1ec831
@ -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);
|
||||
}
|
||||
}
|
78
tests/resources/cloud.xml
Normal file
78
tests/resources/cloud.xml
Normal file
@ -0,0 +1,78 @@
|
||||
<?xml version="1.0"?>
|
||||
<!-- RSS generated by Radio UserLand v8.0.5 on Mon, 13 Oct 2003 18:54:10 GMT -->
|
||||
<rss version="2.0">
|
||||
<channel>
|
||||
<title>Dave's Handsome Radio Blog!</title>
|
||||
<link>http://radio.weblogs.com/0001015/</link>
|
||||
<description>A non-smoking weblog since June 14, 2002.</description>
|
||||
<language>en-us</language>
|
||||
<copyright>Copyright 2003 Dave Winer</copyright>
|
||||
<lastBuildDate>Mon, 13 Oct 2003 18:54:10 GMT</lastBuildDate>
|
||||
<docs>http://backend.userland.com/rss</docs>
|
||||
<generator>Radio UserLand v8.0.5</generator>
|
||||
<managingEditor>dave@userland.com</managingEditor>
|
||||
<webMaster>dave@userland.com</webMaster>
|
||||
<category domain="http://www.weblogs.com/rssUpdates/changes.xml">rssUpdates</category>
|
||||
<skipHours>
|
||||
<hour>0</hour>
|
||||
<hour>23</hour>
|
||||
<hour>1</hour>
|
||||
<hour>2</hour>
|
||||
<hour>3</hour>
|
||||
<hour>22</hour>
|
||||
<hour>17</hour>
|
||||
<hour>11</hour>
|
||||
</skipHours>
|
||||
<cloud domain="radio.xmlstoragesystem.com" port="80" path="/RPC2" registerProcedure="xmlStorageSystem.rssPleaseNotify" protocol="xml-rpc"/>
|
||||
<ttl>60</ttl>
|
||||
<item>
|
||||
<link>http://radio.weblogs.com/0001015/2003/10/13.html#a1866</link>
|
||||
<description><A href="http://andrea.editthispage.com/"><IMG height=100 alt="A picture named andrea.jpg" hspace=15 src="http://radio.weblogs.com/0001015/images/2003/10/13/andrea.jpg" width=45 align=right vspace=5 border=0></A><A href="http://andrea.editthispage.com/"><IMG height=100 alt="A picture named andrea.jpg" hspace=15 src="http://radio.weblogs.com/0001015/images/2003/10/13/andrea.jpg" width=45 align=right vspace=5 border=0></A><A href="http://andrea.editthispage.com/"><IMG height=100 alt="A picture named andrea.jpg" hspace=15 src="http://radio.weblogs.com/0001015/images/2003/10/13/andrea.jpg" width=45 align=right vspace=5 border=0></A><A href="http://andrea.editthispage.com/"><IMG height=100 alt="A picture named andrea.jpg" hspace=15 src="http://radio.weblogs.com/0001015/images/2003/10/13/andrea.jpg" width=45 align=right vspace=5 border=0></A><A href="http://andrea.editthispage.com/"><IMG height=100 alt="A picture named andrea.jpg" hspace=15 src="http://radio.weblogs.com/0001015/images/2003/10/13/andrea.jpg" width=45 align=right vspace=5 border=0></A></description>
|
||||
<guid>http://radio.weblogs.com/0001015/2003/10/13.html#a1866</guid>
|
||||
<pubDate>Mon, 13 Oct 2003 18:54:09 GMT</pubDate>
|
||||
<comments>http://blogs.law.harvard.edu/comments?u=1015&amp;p=1866&amp;link=http%3A%2F%2Fradio.weblogs.com%2F0001015%2F2003%2F10%2F13.html%23a1866</comments>
|
||||
</item>
|
||||
<item>
|
||||
<link>http://radio.weblogs.com/0001015/2003/10/12.html#a1865</link>
|
||||
<description><A href="http://blogs.law.harvard.edu/crimson1/pictures/viewer$747"><IMG height=89 alt="A picture named cousinJoey.jpg" hspace=15 src="http://radio.weblogs.com/0001015/images/2003/10/12/cousinJoey.jpg" width=65 align=right vspace=5 border=0></A><A href="http://blogs.law.harvard.edu/crimson1/pictures/viewer$747"><IMG height=89 alt="A picture named cousinJoey.jpg" hspace=15 src="http://radio.weblogs.com/0001015/images/2003/10/12/cousinJoey.jpg" width=65 align=right vspace=5 border=0></A><A href="http://blogs.law.harvard.edu/crimson1/pictures/viewer$747"><IMG height=89 alt="A picture named cousinJoey.jpg" hspace=15 src="http://radio.weblogs.com/0001015/images/2003/10/12/cousinJoey.jpg" width=65 align=right vspace=5 border=0></A><A href="http://blogs.law.harvard.edu/crimson1/pictures/viewer$747"><IMG height=89 alt="A picture named cousinJoey.jpg" hspace=15 src="http://radio.weblogs.com/0001015/images/2003/10/12/cousinJoey.jpg" width=65 align=right vspace=5 border=0></A></description>
|
||||
<guid>http://radio.weblogs.com/0001015/2003/10/12.html#a1865</guid>
|
||||
<pubDate>Sun, 12 Oct 2003 20:42:30 GMT</pubDate>
|
||||
<comments>http://blogs.law.harvard.edu/comments?u=1015&amp;p=1865&amp;link=http%3A%2F%2Fradio.weblogs.com%2F0001015%2F2003%2F10%2F12.html%23a1865</comments>
|
||||
</item>
|
||||
<item>
|
||||
<link>http://radio.weblogs.com/0001015/2003/10/08.html#a1864</link>
|
||||
<description><A href="http://radio.weblogs.com/0001015/images/2002/06/04/yourarespecial.gif"><IMG height=52 alt="You are so special." hspace=15 src="http://radio.weblogs.com/0001015/images/2002/06/04/mrrogers.gif" width=45 align=right vspace=5 border=0></A><A href="http://radio.weblogs.com/0001015/images/2002/06/04/yourarespecial.gif"><IMG height=52 alt="You are so special." hspace=15 src="http://radio.weblogs.com/0001015/images/2002/06/04/mrrogers.gif" width=45 align=right vspace=5 border=0></A><A href="http://radio.weblogs.com/0001015/images/2002/06/04/yourarespecial.gif"><IMG height=52 alt="You are so special." hspace=15 src="http://radio.weblogs.com/0001015/images/2002/06/04/mrrogers.gif" width=45 align=right vspace=5 border=0></A><A href="http://radio.weblogs.com/0001015/images/2002/06/04/yourarespecial.gif"><IMG height=52 alt="You are so special." hspace=15 src="http://radio.weblogs.com/0001015/images/2002/06/04/mrrogers.gif" width=45 align=right vspace=5 border=0></A><A href="http://radio.weblogs.com/0001015/images/2002/06/04/yourarespecial.gif"><IMG height=52 alt="You are so special." hspace=15 src="http://radio.weblogs.com/0001015/images/2002/06/04/mrrogers.gif" width=45 align=right vspace=5 border=0></A></description>
|
||||
<guid>http://radio.weblogs.com/0001015/2003/10/08.html#a1864</guid>
|
||||
<pubDate>Wed, 08 Oct 2003 13:22:16 GMT</pubDate>
|
||||
<comments>http://blogs.law.harvard.edu/comments?u=1015&amp;p=1864&amp;link=http%3A%2F%2Fradio.weblogs.com%2F0001015%2F2003%2F10%2F08.html%23a1864</comments>
|
||||
</item>
|
||||
<item>
|
||||
<link>http://radio.weblogs.com/0001015/2003/10/06.html#a1863</link>
|
||||
<description><A href="http://www.state.gov/secretary/rm/2003/17300.htm"><IMG height=51 alt="A picture named powell.jpg" hspace=15 src="http://radio.weblogs.com/0001015/images/2003/10/06/powell.jpg" width=45 align=right vspace=5 border=0></A><A href="http://www.state.gov/secretary/rm/2003/17300.htm"><IMG height=51 alt="A picture named powell.jpg" hspace=15 src="http://radio.weblogs.com/0001015/images/2003/10/06/powell.jpg" width=45 align=right vspace=5 border=0></A><A href="http://www.state.gov/secretary/rm/2003/17300.htm"><IMG height=51 alt="A picture named powell.jpg" hspace=15 src="http://radio.weblogs.com/0001015/images/2003/10/06/powell.jpg" width=45 align=right vspace=5 border=0></A><A href="http://www.state.gov/secretary/rm/2003/17300.htm"><IMG height=51 alt="A picture named powell.jpg" hspace=15 src="http://radio.weblogs.com/0001015/images/2003/10/06/powell.jpg" width=45 align=right vspace=5 border=0></A><A href="http://www.state.gov/secretary/rm/2003/17300.htm"><IMG height=51 alt="A picture named powell.jpg" hspace=15 src="http://radio.weblogs.com/0001015/images/2003/10/06/powell.jpg" width=45 align=right vspace=5 border=0></A></description>
|
||||
<guid>http://radio.weblogs.com/0001015/2003/10/06.html#a1863</guid>
|
||||
<pubDate>Mon, 06 Oct 2003 13:37:40 GMT</pubDate>
|
||||
<comments>http://blogs.law.harvard.edu/comments?u=1015&amp;p=1863&amp;link=http%3A%2F%2Fradio.weblogs.com%2F0001015%2F2003%2F10%2F06.html%23a1863</comments>
|
||||
</item>
|
||||
<item>
|
||||
<link>http://radio.weblogs.com/0001015/2003/10/01.html#a1862</link>
|
||||
<description><A href="http://127.0.0.1:5335/xxx"><IMG height=80 alt="A picture named retard.gif" hspace=15 src="http://radio.weblogs.com/0001015/images/2003/10/01/retard.gif" width=53 align=right vspace=5 border=0></A><A href="http://127.0.0.1:5335/xxx"><IMG height=80 alt="A picture named retard.gif" hspace=15 src="http://radio.weblogs.com/0001015/images/2003/10/01/retard.gif" width=53 align=right vspace=5 border=0></A><A href="http://127.0.0.1:5335/xxx"><IMG height=80 alt="A picture named retard.gif" hspace=15 src="http://radio.weblogs.com/0001015/images/2003/10/01/retard.gif" width=53 align=right vspace=5 border=0></A><A href="http://127.0.0.1:5335/xxx"><IMG height=80 alt="A picture named retard.gif" hspace=15 src="http://radio.weblogs.com/0001015/images/2003/10/01/retard.gif" width=53 align=right vspace=5 border=0></A><A href="http://127.0.0.1:5335/xxx"><IMG height=80 alt="A picture named retard.gif" hspace=15 src="http://radio.weblogs.com/0001015/images/2003/10/01/retard.gif" width=53 align=right vspace=5 border=0></A></description>
|
||||
<guid>http://radio.weblogs.com/0001015/2003/10/01.html#a1862</guid>
|
||||
<pubDate>Wed, 01 Oct 2003 18:26:11 GMT</pubDate>
|
||||
<comments>http://blogs.law.harvard.edu/comments?u=1015&amp;p=1862&amp;link=http%3A%2F%2Fradio.weblogs.com%2F0001015%2F2003%2F10%2F01.html%23a1862</comments>
|
||||
</item>
|
||||
<item>
|
||||
<link>http://radio.weblogs.com/0001015/2003/09/26.html#a1861</link>
|
||||
<description><A href="http://127.0.0.1:5335/xxx"><IMG height=77 alt="A picture named allen.jpg" hspace=15 src="http://radio.weblogs.com/0001015/images/2003/09/26/allen.jpg" width=65 align=right vspace=5 border=0></A><A href="http://127.0.0.1:5335/xxx"><IMG height=77 alt="A picture named allen.jpg" hspace=15 src="http://radio.weblogs.com/0001015/images/2003/09/26/allen.jpg" width=65 align=right vspace=5 border=0></A><A href="http://127.0.0.1:5335/xxx"><IMG height=77 alt="A picture named allen.jpg" hspace=15 src="http://radio.weblogs.com/0001015/images/2003/09/26/allen.jpg" width=65 align=right vspace=5 border=0></A><A href="http://127.0.0.1:5335/xxx"><IMG height=77 alt="A picture named allen.jpg" hspace=15 src="http://radio.weblogs.com/0001015/images/2003/09/26/allen.jpg" width=65 align=right vspace=5 border=0></A><A href="http://127.0.0.1:5335/xxx"><IMG height=77 alt="A picture named allen.jpg" hspace=15 src="http://radio.weblogs.com/0001015/images/2003/09/26/allen.jpg" width=65 align=right vspace=5 border=0></A></description>
|
||||
<guid>http://radio.weblogs.com/0001015/2003/09/26.html#a1861</guid>
|
||||
<pubDate>Fri, 26 Sep 2003 13:29:36 GMT</pubDate>
|
||||
<comments>http://blogs.law.harvard.edu/comments?u=1015&amp;p=1861&amp;link=http%3A%2F%2Fradio.weblogs.com%2F0001015%2F2003%2F09%2F26.html%23a1861</comments>
|
||||
</item>
|
||||
<item>
|
||||
<link>http://radio.weblogs.com/0001015/2003/09/25.html#a1860</link>
|
||||
<description><A href="http://www.command-post.org/2004/2_archives/008524.html"><IMG height=61 alt="A picture named clark.jpg" hspace=15 src="http://radio.weblogs.com/0001015/images/2003/09/25/clark.jpg" width=45 align=right vspace=5 border=0></A><A href="http://www.command-post.org/2004/2_archives/008524.html"><IMG height=61 alt="A picture named clark.jpg" hspace=15 src="http://radio.weblogs.com/0001015/images/2003/09/25/clark.jpg" width=45 align=right vspace=5 border=0></A><A href="http://www.command-post.org/2004/2_archives/008524.html"><IMG height=61 alt="A picture named clark.jpg" hspace=15 src="http://radio.weblogs.com/0001015/images/2003/09/25/clark.jpg" width=45 align=right vspace=5 border=0></A><A href="http://www.command-post.org/2004/2_archives/008524.html"><IMG height=61 alt="A picture named clark.jpg" hspace=15 src="http://radio.weblogs.com/0001015/images/2003/09/25/clark.jpg" width=45 align=right vspace=5 border=0></A><A href="http://www.command-post.org/2004/2_archives/008524.html"><IMG height=61 alt="A picture named clark.jpg" hspace=15 src="http://radio.weblogs.com/0001015/images/2003/09/25/clark.jpg" width=45 align=right vspace=5 border=0></A></description>
|
||||
<guid>http://radio.weblogs.com/0001015/2003/09/25.html#a1860</guid>
|
||||
<pubDate>Thu, 25 Sep 2003 14:08:26 GMT</pubDate>
|
||||
<comments>http://blogs.law.harvard.edu/comments?u=1015&amp;p=1860&amp;link=http%3A%2F%2Fradio.weblogs.com%2F0001015%2F2003%2F09%2F25.html%23a1860</comments>
|
||||
</item>
|
||||
</channel>
|
||||
</rss>
|
Loading…
Reference in New Issue
Block a user