Season   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 74
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 19
c 1
b 0
f 0
dl 0
loc 74
rs 10
wmc 7

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getDisplayName() 0 3 1
A getIdField() 0 3 1
A getStreamableItems() 0 3 1
A getEpisodesString() 0 3 1
A getArtwork() 0 11 3
1
<?php
2
3
/**
4
 * Represents a single TV show season
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 Season extends Base implements IStreamable
11
{
12
	use WatchedIconTrait;
13
	use StreamableTrait;
0 ignored issues
show
Bug introduced by
The trait StreamableTrait requires the property $file which is not provided by Season.
Loading history...
14
15
	/**
16
	 * @var object the season art
17
	 */
18
	public $art;
19
20
	/**
21
	 * @var string the name of the show this season belongs to
22
	 */
23
	public $showtitle;
24
25
	/**
26
	 * @var int the number of episodes. Due to a typo in the XBMC API this is 
27
	 * missing an "s".
28
	 */
29
	public $episode;
30
31
	/**
32
	 * @var int the season number
33
	 */
34
	public $season;
35
36
	/**
37
	 * @var int the season ID
38
	 */
39
	public $seasonid;
40
	
41
	/**
42
	 * @var int the TV show ID
43
	 */
44
	public $tvshowid;
45
46
	public function getIdField()
47
	{
48
		return 'seasonid';
49
	}
50
	
51
	public function getDisplayName()
52
	{
53
		return $this->showtitle.' - '.$this->label;
54
	}
55
56
	/**
57
	 * @return mixed the season poster. If this is the first season of a show 
58
	 * and the artwork is not available we fall back to the show's artwork
59
	 */
60
	public function getArtwork()
61
	{
62
		if (isset($this->art->poster))
63
			return $this->art->poster;
64
		elseif ($this->season === 1)
65
		{
66
			$tvshow = VideoLibrary::getTVShowDetails($this->tvshowid, array('art', 'thumbnail'));
67
			return $tvshow->getArtwork();
68
		}
69
70
		return null;
71
	}
72
	
73
	public function getStreamableItems()
74
	{
75
		return VideoLibrary::getEpisodes($this->tvshowid, $this->season);
76
	}
77
78
	/**
79
	 * @return string a string representing the number of episodes in the season
80
	 */
81
	public function getEpisodesString()
82
	{
83
		return Yii::t('TVShows', '{num} episodes', array('{num}'=>$this->episode));
84
	}
85
86
}
87