Skip to content

Commit

Permalink
Update Watch Models [ci skip]
Browse files Browse the repository at this point in the history
  • Loading branch information
Irfan committed Jan 14, 2021
1 parent 400b12f commit 881ecce
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 54 deletions.
60 changes: 10 additions & 50 deletions src/Model/Watch/EpisodeListItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Jikan\Model\Watch;

use Jikan\Model\Common\AnimeMeta;
use Jikan\Model\Resource\CommonImageResource\CommonImageResource;
use Jikan\Parser\Watch\EpisodeListItemParser;

Expand All @@ -14,24 +15,9 @@ class EpisodeListItem
{

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

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

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

/**
* @var CommonImageResource
*/
private $images;
private $entry;

/**
* @var RecentEpisodeListItem
Expand All @@ -52,52 +38,25 @@ class EpisodeListItem
public static function fromParser(EpisodeListItemParser $parser): EpisodeListItem
{
$instance = new self();
$instance->malId = $parser->getId();
$instance->url = $parser->getUrl();
$instance->name = $parser->getTitle();
$instance->images = CommonImageResource::factory($parser->getImages());
$instance->entry = $parser->getAnimeMeta();
$instance->episodes = $parser->getEpisodes();
$instance->regionLocked = $parser->getRegionLocked();

return $instance;
}

/**
* @return int
* @return AnimeMeta
*/
public function getMalId(): int
public function getEntry(): AnimeMeta
{
return $this->malId;
return $this->entry;
}

/**
* @return string
* @return RecentEpisodeListItem
*/
public function getUrl(): string
{
return $this->url;
}

/**
* @return string
*/
public function getName(): string
{
return $this->name;
}

/**
* @return AnimeResourceImages
*/
public function getImages(): AnimeResourceImages
{
return $this->images;
}

/**
* @return NewEpisodeListItem
*/
public function getEpisodes(): NewEpisodeListItem
public function getEpisodes(): RecentEpisodeListItem
{
return $this->episodes;
}
Expand All @@ -109,4 +68,5 @@ public function isRegionLocked(): bool
{
return $this->regionLocked;
}

}
9 changes: 5 additions & 4 deletions src/Model/Watch/PromotionalVideoListItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class PromotionalVideoListItem
/**
* @var AnimeMeta
*/
private $anime;
private $entry;

/**
* @var YoutubeMeta
Expand All @@ -39,7 +39,7 @@ class PromotionalVideoListItem
public static function fromParser(PromotionalVideoListItemParser $parser): self
{
$instance = new self();
$instance->anime = new AnimeMeta(
$instance->entry = new AnimeMeta(
$parser->getTitle(),
$parser->getUrl(),
$parser->getImages()
Expand All @@ -61,9 +61,9 @@ public function getTitle(): string
/**
* @return AnimeMeta
*/
public function getAnime(): AnimeMeta
public function getEntry(): AnimeMeta
{
return $this->anime;
return $this->entry;
}

/**
Expand All @@ -74,4 +74,5 @@ public function getTrailer(): YoutubeMeta
return $this->trailer;
}


}
10 changes: 10 additions & 0 deletions src/Parser/Watch/EpisodeListItemParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Jikan\Helper\JString;
use Jikan\Helper\Parser;
use Jikan\Model\Common\AnimeMeta;
use Jikan\Model\Watch\EpisodeListItem;
use Jikan\Model\Watch\RecentEpisodeListItem;
use Jikan\Parser\ParserInterface;
Expand Down Expand Up @@ -126,4 +127,13 @@ public function getRegionLocked() : bool

return $node->count();
}

public function getAnimeMeta() : AnimeMeta
{
return new AnimeMeta(
$this->getTitle(),
$this->getUrl(),
$this->getImageUrl()
);
}
}

0 comments on commit 881ecce

Please sign in to comment.