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-2020 |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
|
15
|
|
|
namespace VfacTmdb\Items; |
16
|
|
|
|
17
|
|
|
use VfacTmdb\Abstracts\Item; |
18
|
|
|
use VfacTmdb\Interfaces\Items\TVNetworkInterface; |
19
|
|
|
use VfacTmdb\Interfaces\TmdbInterface; |
20
|
|
|
use VfacTmdb\Results; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* TVNetwork class |
24
|
|
|
* @package Tmdb |
25
|
|
|
* @author Steve Richter <[email protected]> |
26
|
|
|
* @copyright Copyright (c) 2017-2020 |
27
|
|
|
*/ |
28
|
|
|
class TVNetwork extends Item implements TVNetworkInterface |
29
|
|
|
{ |
30
|
|
|
/** |
31
|
|
|
* Constructor |
32
|
|
|
* @param TmdbInterface $tmdb |
33
|
|
|
* @param int $network_id |
34
|
|
|
* @param array $options |
35
|
|
|
*/ |
36
|
84 |
|
public function __construct(TmdbInterface $tmdb, int $network_id, array $options = array()) |
37
|
|
|
{ |
38
|
84 |
|
parent::__construct($tmdb, $network_id, $options, 'network'); |
39
|
81 |
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Get TV Network id |
43
|
|
|
* @return int |
44
|
|
|
*/ |
45
|
9 |
|
public function getId() : int |
46
|
|
|
{ |
47
|
9 |
|
return $this->id; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Get TV Network name |
52
|
|
|
* @return string |
53
|
|
|
*/ |
54
|
6 |
|
public function getName() : string |
55
|
|
|
{ |
56
|
6 |
|
if (isset($this->data->name)) { |
57
|
3 |
|
return $this->data->name; |
58
|
|
|
} |
59
|
3 |
|
return ''; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Get TV Network headquarters |
64
|
|
|
* @return string |
65
|
|
|
*/ |
66
|
6 |
|
public function getHeadquarters() : string |
67
|
|
|
{ |
68
|
6 |
|
if (isset($this->data->headquarters)) { |
69
|
3 |
|
return $this->data->headquarters; |
70
|
|
|
} |
71
|
3 |
|
return ''; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* Get TV Network homepage |
76
|
|
|
* @return string |
77
|
|
|
*/ |
78
|
6 |
|
public function getHomepage() : string |
79
|
|
|
{ |
80
|
6 |
|
if (isset($this->data->homepage)) { |
81
|
3 |
|
return $this->data->homepage; |
82
|
|
|
} |
83
|
3 |
|
return ''; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* Get TV Network origin country |
88
|
|
|
* @return string |
89
|
|
|
*/ |
90
|
6 |
|
public function getOriginCountry() : string |
91
|
|
|
{ |
92
|
6 |
|
if (isset($this->data->origin_country)) { |
93
|
3 |
|
return $this->data->origin_country; |
94
|
|
|
} |
95
|
3 |
|
return ''; |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* Alternative names list |
100
|
|
|
* @return \Generator|Results\AlternativeName |
101
|
|
|
*/ |
102
|
12 |
|
public function getAlternativeNames() : \Generator |
103
|
|
|
{ |
104
|
12 |
|
$params = []; |
105
|
12 |
|
$this->tmdb->checkOptionLanguage($this->params, $params); |
106
|
12 |
|
$data = $this->tmdb->getRequest('network/' . (int) $this->id . '/alternative_names', $params); |
107
|
|
|
|
108
|
12 |
|
foreach ($data->results as $n) { |
109
|
12 |
|
$name = new Results\AlternativeName($this->tmdb, $this->id, $n); |
110
|
12 |
|
yield $name; |
111
|
|
|
} |
112
|
3 |
|
} |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* Logos list |
116
|
|
|
* @return \Generator|Results\Logo |
117
|
|
|
*/ |
118
|
36 |
|
public function getLogos() : \Generator |
119
|
|
|
{ |
120
|
36 |
|
$params = []; |
121
|
36 |
|
$this->tmdb->checkOptionLanguage($this->params, $params); |
122
|
36 |
|
$data = $this->tmdb->getRequest('network/' . (int) $this->id . '/images', $params); |
123
|
|
|
|
124
|
36 |
|
foreach ($data->logos as $logo) { |
125
|
36 |
|
$image = new Results\Logo($this->tmdb, $this->id, $logo); |
126
|
36 |
|
yield $image; |
127
|
|
|
} |
128
|
3 |
|
} |
129
|
|
|
} |
130
|
|
|
|