From ef99fda7d71a80cca9191f7484788f6163edfc2d Mon Sep 17 00:00:00 2001 From: Nate Shoffner Date: Sun, 23 Jan 2022 06:16:43 -0500 Subject: [PATCH 1/2] Allow empty type param --- request/User/UserHistoryRequest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/request/User/UserHistoryRequest.php b/request/User/UserHistoryRequest.php index 7d1fc8f..c5f3ea6 100644 --- a/request/User/UserHistoryRequest.php +++ b/request/User/UserHistoryRequest.php @@ -36,7 +36,7 @@ public function __construct(string $username, $type = '') // "" means empty stri $this->username = $username; if (null !== $type) { - if (!\in_array($type, ['anime', 'manga'])) { + if (!empty($type) && !\in_array($type, ['anime', 'manga'])) { throw new \InvalidArgumentException(sprintf('Type %s is not valid', $type)); } From 33d2764c1cafccc94325196197bd982c59658d28 Mon Sep 17 00:00:00 2001 From: Nate Shoffner Date: Sun, 23 Jan 2022 07:00:49 -0500 Subject: [PATCH 2/2] Fix history meta deserialization --- .../JikanPHP.Model.Common.HistoryMeta.yml | 10 +++ metadata/JikanPHP.Model.User.History.yml | 4 +- model/Common/HistoryMeta.php | 64 +++++++++++++++++++ model/User/History.php | 23 ++++--- 4 files changed, 87 insertions(+), 14 deletions(-) create mode 100644 metadata/JikanPHP.Model.Common.HistoryMeta.yml create mode 100644 model/Common/HistoryMeta.php diff --git a/metadata/JikanPHP.Model.Common.HistoryMeta.yml b/metadata/JikanPHP.Model.Common.HistoryMeta.yml new file mode 100644 index 0000000..26ef719 --- /dev/null +++ b/metadata/JikanPHP.Model.Common.HistoryMeta.yml @@ -0,0 +1,10 @@ +JikanPHP\Model\Common\HistoryMeta: + properties: + malId: + type: int + type: + type: string + name: + type: string + url: + type: string diff --git a/metadata/JikanPHP.Model.User.History.yml b/metadata/JikanPHP.Model.User.History.yml index 305af7c..9ed51e5 100644 --- a/metadata/JikanPHP.Model.User.History.yml +++ b/metadata/JikanPHP.Model.User.History.yml @@ -1,7 +1,7 @@ JikanPHP\Model\User\History: properties: - malUrl: - type: JikanPHP\Model\Common\MalUrl + meta: + type: JikanPHP\Model\Common\HistoryMeta increment: type: int date: diff --git a/model/Common/HistoryMeta.php b/model/Common/HistoryMeta.php new file mode 100644 index 0000000..1f33b93 --- /dev/null +++ b/model/Common/HistoryMeta.php @@ -0,0 +1,64 @@ +url; + } + + /** + * @return int + */ + public function getMalId(): int + { + return $this->malId; + } + + /** + * @return string + */ + public function getType(): string + { + return $this->type; + } + + /** + * @return string + */ + public function getName(): string + { + return $this->name; + } +} diff --git a/model/User/History.php b/model/User/History.php index b0ec3db..29232e6 100644 --- a/model/User/History.php +++ b/model/User/History.php @@ -2,7 +2,7 @@ namespace JikanPHP\Model\User; -use JikanPHP\Model\Common\MalUrl; +use JikanPHP\Model\Common\HistoryMeta; /** * Class History @@ -11,11 +11,10 @@ */ class History { - /** - * @var MalUrl + * @var HistoryMeta */ - private $malUrl; + private HistoryMeta $meta; /** * @var int @@ -27,14 +26,6 @@ class History */ private $date; - /** - * @return MalUrl - */ - public function getMalUrl(): MalUrl - { - return $this->malUrl; - } - /** * @return int */ @@ -50,4 +41,12 @@ public function getDate(): \DateTimeImmutable { return $this->date; } + + /** + * @return HistoryMeta + */ + public function getMeta(): HistoryMeta + { + return $this->meta; + } }