Browse Source

Output of getCategories() should be a CategoryCollection

master
J. King 6 years ago
parent
commit
1a990116a5
  1. 4
      lib/Feed.php
  2. 7
      lib/JSON/Feed.php
  3. 6
      lib/XML/Feed.php

4
lib/Feed.php

@ -6,8 +6,8 @@
declare(strict_types=1); declare(strict_types=1);
namespace JKingWeb\Lax; namespace JKingWeb\Lax;
use JKingWeb\Lax\Person\Person;
use JKingWeb\Lax\Person\Collection as PersonCollection; use JKingWeb\Lax\Person\Collection as PersonCollection;
use JKingWeb\Lax\Category\Collection as CategoryCollection;
abstract class Feed { abstract class Feed {
protected $reqUrl; protected $reqUrl;
@ -61,7 +61,7 @@ abstract class Feed {
* *
* The $humanFriendly parameter only affects Atom categories * The $humanFriendly parameter only affects Atom categories
*/ */
abstract public function getCategories(): array; abstract public function getCategories(): CategoryCollection;
/** General function to fetch the feed identifier */ /** General function to fetch the feed identifier */
abstract public function getId(): string; abstract public function getId(): string;

7
lib/JSON/Feed.php

@ -8,6 +8,7 @@ namespace JKingWeb\Lax\JSON;
use JKingWeb\Lax\Person\Person; use JKingWeb\Lax\Person\Person;
use JKingWeb\Lax\Person\Collection as PersonCollection; use JKingWeb\Lax\Person\Collection as PersonCollection;
use JKingWeb\Lax\Category\Collection as CategoryCollection;
class Feed extends \JKingWeb\Lax\Feed { class Feed extends \JKingWeb\Lax\Feed {
use Construct; use Construct;
@ -52,10 +53,10 @@ class Feed extends \JKingWeb\Lax\Feed {
/** General function to fetch the categories of a feed /** General function to fetch the categories of a feed
* *
* JSON Feed does not have categories at the feed level, so this always returns an empty array * JSON Feed does not have categories at the feed level, so this always returns an empty collection
*/ */
public function getCategories(bool $grouped = false, bool $humanFriendly = true): array { public function getCategories(): CategoryCollection {
return []; return new CategoryCollection;
} }
/** General function to fetch the feed identifier /** General function to fetch the feed identifier

6
lib/XML/Feed.php

@ -6,8 +6,8 @@
declare(strict_types=1); declare(strict_types=1);
namespace JKingWeb\Lax\XML; namespace JKingWeb\Lax\XML;
use JKingWeb\Lax\Person\Person;
use JKingWeb\Lax\Person\Collection as PersonCollection; use JKingWeb\Lax\Person\Collection as PersonCollection;
use JKingWeb\Lax\Category\Collection as CategoryCollection;
class Feed extends \JKingWeb\Lax\Feed { class Feed extends \JKingWeb\Lax\Feed {
use Construct; use Construct;
@ -85,8 +85,8 @@ class Feed extends \JKingWeb\Lax\Feed {
* *
* The $humanFriendly parameter only affects Atom categories * The $humanFriendly parameter only affects Atom categories
*/ */
public function getCategories(): array { public function getCategories(): CategoryCollection {
return $this->getCategoriesAtom() ?? $this->getCategoriesRss2() ?? $this->getCategoriesDC() ?? $this->getCategoriesPod() ?? []; return $this->getCategoriesAtom() ?? $this->getCategoriesRss2() ?? $this->getCategoriesDC() ?? $this->getCategoriesPod() ?? new CategoryCollection;
} }
/** General function to fetch the feed identifier */ /** General function to fetch the feed identifier */

Loading…
Cancel
Save