TVShow::getDisplayName()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 7
rs 10
1
<?php
2
3
/**
4
 * Represents a TV show
5
 *
6
 * @author Sam Stenvall <[email protected]>
7
 * @copyright Copyright &copy; Sam Stenvall 2013-
8
 * @license https://www.gnu.org/licenses/gpl.html The GNU General Public License v3.0
9
 */
10
class TVShow extends Media implements IStreamable
11
{
12
	use StreamableTrait;
13
	use HasPremieredTrait;
14
15
	/**
16
	 * @var object
17
	 */
18
	public $art;
19
20
	/**
21
	 * @var int
22
	 */
23
	public $tvshowid;
24
25
	public function getDisplayName()
26
	{
27
		$name = $this->label;
28
		if (!empty($this->year))
29
			$name .= ' ('.$this->year.')';
30
31
		return $name;
32
	}
33
34
	/**
35
	 * @return string the artwork for the show
36
	 */
37
	public function getArtwork()
38
	{
39
		// Prefer the poster when it's available
40
		if (isset($this->art->poster))
41
			return $this->art->poster;
42
		else
43
			return $this->thumbnail;
44
	}
45
	
46
	public function getStreamableItems()
47
	{
48
		$items = array();
49
		$seasons = VideoLibrary::getSeasons($this->tvshowid);
50
		
51
		// Get all episodes from all the seasons
52
		foreach($seasons as $season)
53
		{
54
			$episodes = VideoLibrary::getEpisodes($this->tvshowid, $season->season);
55
			$items = array_merge($items, $episodes);
56
		}
57
		
58
		return $items;
59
	}
60
	
61
	/**
62
	 * @return string the URL to the show's TVDB page
63
	 */
64
	public function getTVDBUrl()
65
	{
66
		return 'http://www.thetvdb.com/?tab=series&amp;id='.$this->imdbnumber;
67
	}
68
69
}
70