1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
/** |
3
|
|
|
* This file is part of the Tmdb package. |
4
|
|
|
* |
5
|
|
|
* (c) Vincent Faliès <[email protected]> |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
* |
10
|
|
|
* @author Vincent Faliès <[email protected]> |
11
|
|
|
* @copyright Copyright (c) 2017 |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
|
15
|
|
|
namespace VfacTmdb\Abstracts\Items; |
16
|
|
|
|
17
|
|
|
use VfacTmdb\Results; |
18
|
|
|
use VfacTmdb\Abstracts\Item; |
19
|
|
|
use VfacTmdb\Traits\ElementTrait; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* abstract TV item class |
23
|
|
|
* @package Tmdb |
24
|
|
|
* @author Vincent Faliès <[email protected]> |
25
|
|
|
* @copyright Copyright (c) 2017 |
26
|
|
|
*/ |
27
|
|
|
abstract class TVItem extends Item |
28
|
|
|
{ |
29
|
|
|
use ElementTrait; |
|
|
|
|
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Season number |
33
|
|
|
* @var int |
34
|
|
|
*/ |
35
|
|
|
protected $season_number; |
36
|
|
|
/** |
37
|
|
|
* Episode number |
38
|
|
|
* @var int |
39
|
|
|
*/ |
40
|
|
|
protected $episode_number; |
41
|
|
|
/** |
42
|
|
|
* TVShow Id |
43
|
|
|
* @var int |
44
|
|
|
*/ |
45
|
|
|
protected $tv_id; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Get posters params configuration from child object |
49
|
|
|
* @return \stdClass |
50
|
|
|
*/ |
51
|
6 |
|
protected function getPostersParams() : \stdClass |
52
|
|
|
{ |
53
|
6 |
|
$url = 'tv/' . $this->tv_id . '/season/' . $this->season_number; |
54
|
6 |
|
$key = 'posters'; |
55
|
6 |
|
if (isset($this->episode_number)) { |
56
|
3 |
|
$url .= '/episode/' . $this->episode_number; |
57
|
3 |
|
$key = 'stills'; |
58
|
|
|
} |
59
|
6 |
|
$url .= '/images'; |
60
|
|
|
|
61
|
6 |
|
$params = new \stdClass; |
62
|
6 |
|
$params->url = $url; |
63
|
6 |
|
$params->key = $key; |
64
|
|
|
|
65
|
6 |
|
return $params; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* Image posters |
70
|
|
|
* @return \Generator|Results\Image |
71
|
|
|
*/ |
72
|
6 |
|
public function getPosters() : \Generator |
73
|
|
|
{ |
74
|
6 |
|
$params = $this->getPostersParams(); |
75
|
6 |
|
$key = $params->key; |
76
|
|
|
|
77
|
6 |
|
$options = []; |
78
|
6 |
|
$this->tmdb->checkOptionLanguage($this->params, $options); |
79
|
|
|
|
80
|
6 |
|
$data = $this->tmdb->getRequest($params->url, $options); |
81
|
|
|
|
82
|
6 |
|
foreach ($data->$key as $b) { |
83
|
6 |
|
$image = new Results\Image($this->tmdb, $this->id, $b); |
84
|
6 |
|
yield $image; |
85
|
|
|
} |
86
|
6 |
|
} |
87
|
|
|
} |
88
|
|
|
|