-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from srichter/add_tv_networks
Add Logo Result, Name Result, and TVNetwork item
- Loading branch information
Showing
17 changed files
with
1,284 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php declare(strict_types = 1); | ||
/** | ||
* This file is part of the Tmdb package. | ||
* | ||
* (c) Vincent Faliès <vincent@vfac.fr> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* @author Vincent Faliès <vincent@vfac.fr> | ||
* @copyright Copyright (c) 2017-2020 | ||
*/ | ||
|
||
|
||
namespace VfacTmdb\Interfaces\Items; | ||
|
||
/** | ||
* Interface for TVNetwork type object | ||
* @package Tmdb | ||
* @author Steve Richter <steve@nerdbra.in> | ||
* @copyright Copyright (c) 2017-2020 | ||
*/ | ||
interface TVNetworkInterface | ||
{ | ||
|
||
/** | ||
* Id | ||
* @return int | ||
*/ | ||
public function getId() : int; | ||
|
||
/** | ||
* Name | ||
* @return string | ||
*/ | ||
public function getName() : string; | ||
|
||
/** | ||
* Headquarters | ||
* @return string | ||
*/ | ||
public function getHeadquarters() : string; | ||
|
||
/** | ||
* Homepage | ||
* @return string | ||
*/ | ||
public function getHomepage() : string; | ||
|
||
/** | ||
* Origin country | ||
* @return string | ||
*/ | ||
public function getOriginCountry() : string; | ||
|
||
/** | ||
* Logos list | ||
* @return \Generator | ||
*/ | ||
public function getLogos() : \Generator; | ||
|
||
/** | ||
* Alternative names list | ||
* @return \Generator | ||
*/ | ||
public function getAlternativeNames() : \Generator; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,5 +74,4 @@ public function getVideos() : \Generator | |
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
<?php declare(strict_types = 1); | ||
/** | ||
* This file is part of the Tmdb package. | ||
* | ||
* (c) Vincent Faliès <vincent@vfac.fr> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* @author Vincent Faliès <vincent@vfac.fr> | ||
* @copyright Copyright (c) 2017-2020 | ||
*/ | ||
|
||
|
||
namespace VfacTmdb\Items; | ||
|
||
use VfacTmdb\Abstracts\Item; | ||
use VfacTmdb\Interfaces\Items\TVNetworkInterface; | ||
use VfacTmdb\Interfaces\TmdbInterface; | ||
use VfacTmdb\Results; | ||
|
||
/** | ||
* TVNetwork class | ||
* @package Tmdb | ||
* @author Steve Richter <steve@nerdbra.in> | ||
* @copyright Copyright (c) 2017-2020 | ||
*/ | ||
class TVNetwork extends Item implements TVNetworkInterface | ||
{ | ||
/** | ||
* Constructor | ||
* @param TmdbInterface $tmdb | ||
* @param int $network_id | ||
* @param array $options | ||
*/ | ||
public function __construct(TmdbInterface $tmdb, int $network_id, array $options = array()) | ||
{ | ||
parent::__construct($tmdb, $network_id, $options, 'network'); | ||
} | ||
|
||
/** | ||
* Get TV Network id | ||
* @return int | ||
*/ | ||
public function getId() : int | ||
{ | ||
return $this->id; | ||
} | ||
|
||
/** | ||
* Get TV Network name | ||
* @return string | ||
*/ | ||
public function getName() : string | ||
{ | ||
if (isset($this->data->name)) { | ||
return $this->data->name; | ||
} | ||
return ''; | ||
} | ||
|
||
/** | ||
* Get TV Network headquarters | ||
* @return string | ||
*/ | ||
public function getHeadquarters() : string | ||
{ | ||
if (isset($this->data->headquarters)) { | ||
return $this->data->headquarters; | ||
} | ||
return ''; | ||
} | ||
|
||
/** | ||
* Get TV Network homepage | ||
* @return string | ||
*/ | ||
public function getHomepage() : string | ||
{ | ||
if (isset($this->data->homepage)) { | ||
return $this->data->homepage; | ||
} | ||
return ''; | ||
} | ||
|
||
/** | ||
* Get TV Network origin country | ||
* @return string | ||
*/ | ||
public function getOriginCountry() : string | ||
{ | ||
if (isset($this->data->origin_country)) { | ||
return $this->data->origin_country; | ||
} | ||
return ''; | ||
} | ||
|
||
/** | ||
* Alternative names list | ||
* @return \Generator|Results\AlternativeName | ||
*/ | ||
public function getAlternativeNames() : \Generator | ||
{ | ||
$params = []; | ||
$this->tmdb->checkOptionLanguage($this->params, $params); | ||
$data = $this->tmdb->getRequest('network/' . (int) $this->id . '/alternative_names', $params); | ||
|
||
foreach ($data->results as $n) { | ||
$name = new Results\AlternativeName($this->tmdb, $this->id, $n); | ||
yield $name; | ||
} | ||
} | ||
|
||
/** | ||
* Logos list | ||
* @return \Generator|Results\Logo | ||
*/ | ||
public function getLogos() : \Generator | ||
{ | ||
$params = []; | ||
$this->tmdb->checkOptionLanguage($this->params, $params); | ||
$data = $this->tmdb->getRequest('network/' . (int) $this->id . '/images', $params); | ||
|
||
foreach ($data->logos as $logo) { | ||
$image = new Results\Logo($this->tmdb, $this->id, $logo); | ||
yield $image; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<?php declare(strict_types = 1); | ||
/** | ||
* This file is part of the Tmdb package. | ||
* | ||
* (c) Vincent Faliès <vincent@vfac.fr> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* @author Vincent Faliès <vincent@vfac.fr> | ||
* @copyright Copyright (c) 2017-2020 | ||
*/ | ||
|
||
|
||
namespace VfacTmdb\Results; | ||
|
||
use VfacTmdb\Abstracts\Results; | ||
use VfacTmdb\Interfaces\TmdbInterface; | ||
|
||
/** | ||
* Class to manipulate a name result | ||
* @package Tmdb | ||
* @author Steve Richter <steve@nerdbra.in> | ||
* @copyright Copyright (c) 2017-2020 | ||
*/ | ||
class AlternativeName extends Results | ||
{ | ||
/** | ||
* Id | ||
* @var int | ||
*/ | ||
protected $id; | ||
/** | ||
* Name | ||
* @var string | ||
*/ | ||
protected $name; | ||
/** | ||
* Type | ||
* @var string | ||
*/ | ||
protected $type; | ||
|
||
/** | ||
* Constructor | ||
* @param TmdbInterface $tmdb | ||
* @param int $id | ||
* @param \stdClass $result | ||
*/ | ||
public function __construct(TmdbInterface $tmdb, int $id, \stdClass $result) | ||
{ | ||
$result->id = $id; | ||
parent::__construct($tmdb, $result); | ||
|
||
$this->id = (int) $id; | ||
$this->name = $result->name; | ||
$this->type = $result->type; | ||
} | ||
|
||
/** | ||
* Id | ||
* @return int | ||
*/ | ||
public function getId() : int | ||
{ | ||
return $this->id; | ||
} | ||
|
||
/** | ||
* Name | ||
* @return string | ||
*/ | ||
public function getName() : string | ||
{ | ||
return $this->name; | ||
} | ||
|
||
/** | ||
* Type | ||
* @return string | ||
*/ | ||
public function getType() : string | ||
{ | ||
return $this->type; | ||
} | ||
} |
Oops, something went wrong.