diff --git a/src/Entity/Channel.php b/src/Entity/Channel.php index d4d958f..59aee30 100644 --- a/src/Entity/Channel.php +++ b/src/Entity/Channel.php @@ -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 */ diff --git a/src/Entity/Channel/Category.php b/src/Entity/Channel/Category.php new file mode 100644 index 0000000..acfc4f1 --- /dev/null +++ b/src/Entity/Channel/Category.php @@ -0,0 +1,33 @@ +isObjectValid($this); + } catch (\ReflectionException $e) { + return false; + } + } + + public function toArray(): array + { + return get_object_vars($this); + } +} \ No newline at end of file diff --git a/src/Entity/Channel/Cloud.php b/src/Entity/Channel/Cloud.php new file mode 100644 index 0000000..95f991f --- /dev/null +++ b/src/Entity/Channel/Cloud.php @@ -0,0 +1,47 @@ + + + public function isValid(): bool + { + try { + return (new Validator())->isObjectValid($this); + } catch (\ReflectionException $e) { + return false; + } + } + + public function toArray(): array + { + return get_object_vars($this); + } +} \ No newline at end of file diff --git a/src/Entity/Item.php b/src/Entity/Item.php index 6b795b6..1149870 100644 --- a/src/Entity/Item.php +++ b/src/Entity/Item.php @@ -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[] diff --git a/src/Entity/Item/Category.php b/src/Entity/Item/Category.php new file mode 100644 index 0000000..6d8c318 --- /dev/null +++ b/src/Entity/Item/Category.php @@ -0,0 +1,33 @@ +isObjectValid($this); + } catch (\ReflectionException $e) { + return false; + } + } + + public function toArray(): array + { + return get_object_vars($this); + } +} \ No newline at end of file diff --git a/src/Entity/Item/Enclosure.php b/src/Entity/Item/Enclosure.php new file mode 100644 index 0000000..4590b23 --- /dev/null +++ b/src/Entity/Item/Enclosure.php @@ -0,0 +1,39 @@ +isObjectValid($this); + } catch (\ReflectionException $e) { + return false; + } + } + + public function toArray(): array + { + return get_object_vars($this); + } +} \ No newline at end of file diff --git a/src/Entity/Item/Source.php b/src/Entity/Item/Source.php new file mode 100644 index 0000000..ddbaf55 --- /dev/null +++ b/src/Entity/Item/Source.php @@ -0,0 +1,34 @@ +isObjectValid($this); + } catch (\ReflectionException $e) { + return false; + } + } + + public function toArray(): array + { + return get_object_vars($this); + } +} \ No newline at end of file diff --git a/tests/resources/cloud.xml b/tests/resources/cloud.xml new file mode 100644 index 0000000..2c4a12e --- /dev/null +++ b/tests/resources/cloud.xml @@ -0,0 +1,78 @@ + + + + + Dave's Handsome Radio Blog! + http://radio.weblogs.com/0001015/ + A non-smoking weblog since June 14, 2002. + en-us + Copyright 2003 Dave Winer + Mon, 13 Oct 2003 18:54:10 GMT + http://backend.userland.com/rss + Radio UserLand v8.0.5 + dave@userland.com + dave@userland.com + rssUpdates + + 0 + 23 + 1 + 2 + 3 + 22 + 17 + 11 + + + 60 + + http://radio.weblogs.com/0001015/2003/10/13.html#a1866 + <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> + http://radio.weblogs.com/0001015/2003/10/13.html#a1866 + Mon, 13 Oct 2003 18:54:09 GMT + 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 + + + http://radio.weblogs.com/0001015/2003/10/12.html#a1865 + <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> + http://radio.weblogs.com/0001015/2003/10/12.html#a1865 + Sun, 12 Oct 2003 20:42:30 GMT + 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 + + + http://radio.weblogs.com/0001015/2003/10/08.html#a1864 + <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> + http://radio.weblogs.com/0001015/2003/10/08.html#a1864 + Wed, 08 Oct 2003 13:22:16 GMT + 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 + + + http://radio.weblogs.com/0001015/2003/10/06.html#a1863 + <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> + http://radio.weblogs.com/0001015/2003/10/06.html#a1863 + Mon, 06 Oct 2003 13:37:40 GMT + 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 + + + http://radio.weblogs.com/0001015/2003/10/01.html#a1862 + <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> + http://radio.weblogs.com/0001015/2003/10/01.html#a1862 + Wed, 01 Oct 2003 18:26:11 GMT + 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 + + + http://radio.weblogs.com/0001015/2003/09/26.html#a1861 + <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> + http://radio.weblogs.com/0001015/2003/09/26.html#a1861 + Fri, 26 Sep 2003 13:29:36 GMT + 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 + + + http://radio.weblogs.com/0001015/2003/09/25.html#a1860 + <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> + http://radio.weblogs.com/0001015/2003/09/25.html#a1860 + Thu, 25 Sep 2003 14:08:26 GMT + 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 + + +