Skip to content
This repository has been archived by the owner on Jun 9, 2023. It is now read-only.

Commit

Permalink
Added function for get seasons number
Browse files Browse the repository at this point in the history
  • Loading branch information
joserick committed Apr 4, 2019
1 parent ac3567d commit 8d361f4
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Server/Library/Item/Show.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,16 @@ public function getRandomEpisode()
$randomNumber = mt_rand(0, $ceiling);
return $allEpisodes[$randomNumber];
}

/**
* Returns an integer of the seasons number for the instantiated show.
*
* @uses Plex_Server_Library_ItemGrandparentAbstract::getChildCount()
*
* @return integer Count of seasons of the Plex library Show.
*/
public function getCountSeasons()
{
return $this->getChildCount();
}
}
36 changes: 36 additions & 0 deletions Server/Library/ItemGrandparentAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ abstract class Plex_Server_Library_ItemGrandparentAbstract
*/
protected $contentRating;

/**
* Number of child items (Plex_Server_Library_ItemChildAbstract) that are
* associated with the grandparent. In the case of Shows this is Seasons.
* @var integer
*/
protected $childCount;

/**
* Sets an array of attribues, if they exist, to the corresponding class
* member.
Expand Down Expand Up @@ -118,6 +125,9 @@ public function setAttributes($attribute)
if (isset($attribute['contentRating'])) {
$this->setContentRating($attribute['contentRating']);
}
if (isset($attribute['childCount'])) {
$this->setChildCount($attribute['childCount']);
}
}

/**
Expand Down Expand Up @@ -275,4 +285,30 @@ public function setContentRating($contentRating)
{
$this->contentRating = $contentRating;
}

/**
* Returns the item's child count.
*
* @uses Plex_Server_Library_ItemGrandparentAbstract::$childCount
*
* @return integer The item's child count.
*/
public function getChildCount()
{
return (int) $this->childCount;
}

/**
* Sets the item's child count.
*
* @param integer $childCount The item's child count.
*
* @uses Plex_Server_Library_ItemGrandparentAbstract::$childCount
*
* @return void
*/
public function setChildCount($childCount)
{
$this->childCount = $childCount;
}
}

0 comments on commit 8d361f4

Please sign in to comment.