From ac3567d0ed23dc5078efd02ead8587e3b6f3e962 Mon Sep 17 00:00:00 2001 From: Jose Erick Carreon G Date: Wed, 3 Apr 2019 20:37:40 -0600 Subject: [PATCH] Added item type tag --- Plex.php | 2 + Server/Library/Item/Tag/Tag.php | 161 +++++++++++++++++++++++ Server/Library/Item/Tag/TagInterface.php | 87 ++++++++++++ 3 files changed, 250 insertions(+) create mode 100644 Server/Library/Item/Tag/Tag.php create mode 100644 Server/Library/Item/Tag/TagInterface.php diff --git a/Plex.php b/Plex.php index f64a412..3ebb407 100644 --- a/Plex.php +++ b/Plex.php @@ -49,6 +49,8 @@ require_once(sprintf('%s/Server/Library/Item/Media/File/File.php', $phpPlexDir)); require_once(sprintf('%s/Server/Library/Item/Media/MediaInterface.php', $phpPlexDir)); require_once(sprintf('%s/Server/Library/Item/Media/Media.php', $phpPlexDir)); +require_once(sprintf('%s/Server/Library/Item/Tag/TagInterface.php', $phpPlexDir)); +require_once(sprintf('%s/Server/Library/Item/Tag/Tag.php', $phpPlexDir)); require_once(sprintf('%s/Server/Library/ItemInterface.php', $phpPlexDir)); require_once(sprintf('%s/Server/Library/ItemAbstract.php', $phpPlexDir)); require_once(sprintf('%s/Server/Library/ItemGrandparentAbstract.php', $phpPlexDir)); diff --git a/Server/Library/Item/Tag/Tag.php b/Server/Library/Item/Tag/Tag.php new file mode 100644 index 0000000..a4f6c90 --- /dev/null +++ b/Server/Library/Item/Tag/Tag.php @@ -0,0 +1,161 @@ + Jose Erick Carreon + * @copyright (c) 2019 Jose Erick Carreon + * @license http://www.gnu.org/licenses/gpl-3.0.html GNU Public Licence (GPLv3) + * @version 0.0.1 + * + * This file is part of php-plex. + * + * php-plex is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * php-plex is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +/** + * Class that represents the tag info a Plex Server Library Item. + * + * @category php-plex + * @package Plex_Server_Library + * @subpackage Plex_Server_Library_Item + * @author Jose Erick Carreon + * @copyright (c) 2019 Jose Erick Carreon + * @license http://www.gnu.org/licenses/gpl-3.0.html GNU Public Licence (GPLv3) + * @version 0.0.1 + */ +class Plex_Server_Library_Item_Tag + implements Plex_Server_Library_Item_TagInterface +{ + /** + * ID of the tag info. + * @var integer + */ + private $id; + + /** + * Filter of the tag info. + * @var string + */ + private $filter; + + /** + * Tag data of the tag info. + * @var string + */ + private $tag; + + /** + * Sets an array of tag info to their corresponding class members. + * + * @param array $rawTag An array of the raw tag info returned from the + * Plex HTTP API. + * + * @uses Plex_Server_Library_Item_Tag::setId() + * @uses Plex_Server_Library_Item_Tag::setFilter() + * @uses Plex_Server_Library_Item_Tag::setTag() + * + * @return void + */ + public function __construct($rawTag) + { + if (isset($rawTag['id'])) { + $this->setId($rawTag['id']); + } + if (isset($rawTag['filter'])) { + $this->setFilter($rawTag['filter']); + } + if (isset($rawTag['tag'])) { + $this->setTag($rawTag['tag']); + } + } + + /** + * Returns the ID of the tag info. + * + * @uses Plex_Server_Library_Item_Tag::$id + * + * @return integer The ID of the tag info. + */ + public function getId() + { + return $this->id; + } + + /** + * Sets the ID of the tag info. + * + * @param integer $id The ID of the tag info. + * + * @uses Plex_Server_Library_Item_Tag::$id + * + * @return void + */ + public function setId($id) + { + $this->id = $id; + } + + /** + * Returns the filter of the tag info. + * + * @uses Plex_Server_Library_Item_Tag::$filter + * + * @return integer The filter of the tag info. + */ + public function getFilter() + { + return $this->filter; + } + + /** + * Sets the filter of the tag info. + * + * @param integer $filter The filter of the tag info. + * + * @uses Plex_Server_Library_Item_Tag::$filter + * + * @return void + */ + public function setFilter($filter) + { + $this->filter = $filter; + } + + /** + * Returns the tag data of the tag info. + * + * @uses Plex_Server_Library_Item_Tag::$tag + * + * @return integer The tag of the tag info. + */ + public function getTag() + { + return $this->tag; + } + + /** + * Sets the tag data of the tag info. + * + * @param integer $tag The tag of the tag info. + * + * @uses Plex_Server_Library_Item_Tag::$tag + * + * @return void + */ + public function setTag($tag) + { + $this->tag = $tag; + } +} diff --git a/Server/Library/Item/Tag/TagInterface.php b/Server/Library/Item/Tag/TagInterface.php new file mode 100644 index 0000000..e06b0b9 --- /dev/null +++ b/Server/Library/Item/Tag/TagInterface.php @@ -0,0 +1,87 @@ + Jose Erick Carreon + * @copyright (c) 2019 Jose Erick Carreon + * @license http://www.gnu.org/licenses/gpl-3.0.html GNU Public Licence (GPLv3) + * @version 0.0.1 + * + * This file is part of php-plex. + * + * php-plex is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * php-plex is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +/** + * Interface that represents the tag info a Plex Server Library Item. + * + * @category php-plex + * @package Plex_Server_Library + * @subpackage Plex_Server_Library_Item + * @author Jose Erick Carreon + * @copyright (c) 2019 Jose Erick Carreon + * @license http://www.gnu.org/licenses/gpl-3.0.html GNU Public Licence (GPLv3) + * @version 0.0.1 + */ +interface Plex_Server_Library_Item_TagInterface +{ + /** + * Returns the ID of the tag info. + * + * @return integer The ID of the tag info. + */ + public function getId(); + + /** + * Sets the ID of the tag info. + * + * @param integer $id The ID of the tag info. + * + * @return void + */ + public function setId($id); + + /** + * Returns the filter of the tag info. + * + * @return integer The filter of the tag info. + */ + public function getFilter(); + + /** + * Sets the filter of the tag info. + * + * @param integer $filter The filter of the tag info. + * + * @return void + */ + public function setFilter($filter); + + /** + * Returns the data tag of the tag info. + * + * @return integer The tag of the tag info. + */ + public function getTag(); + + /** + * Sets the tag data of the tag info. + * + * @param integer $tag The tag of the tag info. + * + * @return void + */ + public function setTag($tag); +}