Passed
Push — master ( d021a5...a13070 )
by Sam
03:47 queued 12s
created

Media   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 91
Duplicated Lines 0 %

Coupling/Cohesion

Components 4
Dependencies 2

Importance

Changes 0
Metric Value
wmc 7
lcom 4
cbo 2
dl 0
loc 91
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getPlot() 0 3 2
A getGenreString() 0 3 1
A hasRating() 0 3 1
A getRuntimeString() 0 3 2
A getRating() 0 3 1
1
<?php
2
3
/**
4
 * Base class for all media items (movies, TV shows, episodes). This class 
5
 * contains fields that can be found in all the base classes.
6
 *
7
 * @author Sam Stenvall <[email protected]>
8
 * @copyright Copyright &copy; Sam Stenvall 2013-
9
 * @license https://www.gnu.org/licenses/gpl.html The GNU General Public License v3.0
10
 * 
11
 * Properties and methods from traits
12
 * @property string $file the item file
13
 * @method ItemLink[] getItemLinks() the item links
14
 * @method string getWatchedIcon() the HTML for a watched icon
15
 */
16
abstract class Media extends Base
17
{
18
	use WatchedIconTrait;
19
20
	/**
21
	 * @var float
22
	 */
23
	public $rating;
24
25
	/**
26
	 * @var int
27
	 */
28
	public $runtime;
29
30
	/**
31
	 * @var int
32
	 */
33
	public $year;
34
35
	/**
36
	 * @var array
37
	 */
38
	public $genre = array();
39
40
	/**
41
	 * @var Actor[]
42
	 */
43
	public $cast;
44
45
	/**
46
	 * @var string
47
	 */
48
	public $mpaa;
49
50
	/**
51
	 * @var string
52
	 */
53
	public $plot;
54
55
	/**
56
	 * @var string
57
	 */
58
	public $imdbnumber;
59
60
	/**
61
	 * @var object
62
	 */
63
	public $streamdetails;
64
65
	/**
66
	 * Returns the list of genres as a string
67
	 * @return string
68
	 */
69
	public function getGenreString()
70
	{
71
		return implode(' / ', $this->genre);
72
	}
73
74
	/**
75
	 * @return string the plot for the item, or "Not available" if it's missing
76
	 */
77
	public function getPlot()
78
	{
79
		return !empty($this->plot) ? $this->plot : Yii::t('Misc', 'Not available');
80
	}
81
82
	/**
83
	 * @return boolean whether or not the item has a rating
84
	 */
85
	public function hasRating()
86
	{
87
		return !!$this->rating;
88
	}
89
90
	/**
91
	 * @return string the rating for the item (formatted)
92
	 */
93
	public function getRating()
94
	{
95
		return number_format($this->rating, 1);
96
	}
97
98
	/**
99
	 * @return string the runtime string or null if runtime is not available
100
	 */
101
	public function getRuntimeString()
102
	{
103
		return $this->runtime ? (int)($this->runtime / 60).' min' : null;
104
	}
105
106
}
107