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