Skip to content

Commit

Permalink
Fix history meta deserialization
Browse files Browse the repository at this point in the history
  • Loading branch information
NateShoffner committed Jan 23, 2022
1 parent ef99fda commit 33d2764
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 14 deletions.
10 changes: 10 additions & 0 deletions metadata/JikanPHP.Model.Common.HistoryMeta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
JikanPHP\Model\Common\HistoryMeta:
properties:
malId:
type: int
type:
type: string
name:
type: string
url:
type: string
4 changes: 2 additions & 2 deletions metadata/JikanPHP.Model.User.History.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
64 changes: 64 additions & 0 deletions model/Common/HistoryMeta.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php

namespace JikanPHP\Model\Common;

/**
* Class HistoryMeta
*
* @package JikanPHP\Model
*/
class HistoryMeta
{

/**
* @var string
*/
private $url;

/**
* @var int
*/
private $malId;

/**
* @var string
*/
private $type;

/**
* @var string
*/
private $name;

/**
* @return string
*/
public function getUrl(): string
{
return $this->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;
}
}
23 changes: 11 additions & 12 deletions model/User/History.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace JikanPHP\Model\User;

use JikanPHP\Model\Common\MalUrl;
use JikanPHP\Model\Common\HistoryMeta;

/**
* Class History
Expand All @@ -11,11 +11,10 @@
*/
class History
{

/**
* @var MalUrl
* @var HistoryMeta
*/
private $malUrl;
private HistoryMeta $meta;

/**
* @var int
Expand All @@ -27,14 +26,6 @@ class History
*/
private $date;

/**
* @return MalUrl
*/
public function getMalUrl(): MalUrl
{
return $this->malUrl;
}

/**
* @return int
*/
Expand All @@ -50,4 +41,12 @@ public function getDate(): \DateTimeImmutable
{
return $this->date;
}

/**
* @return HistoryMeta
*/
public function getMeta(): HistoryMeta
{
return $this->meta;
}
}

0 comments on commit 33d2764

Please sign in to comment.