Movie::getDateAdded()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
/**
4
 * Represents a movie
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
 * Virtual class properties:
11
 * 
12
 * @property int $votes
13
 */
14
class Movie extends File implements IStreamable
15
{
16
	use HasPremieredTrait;
17
18
	/**
19
	 * @var int
20
	 */
21
	public $movieid;
22
23
	/**
24
	 * @var string
25
	 */
26
	public $tagline;
27
	
28
	/**
29
	 * @var array the directors for this movie
30
	 */
31
	public $director;
32
33
	/**
34
	 * @var string the date the movie was added to the library 
35
	 */
36
	public $dateadded;
37
38
	/**
39
	 * @var object the movie art
40
	 */
41
	public $art;
42
43
	/**
44
	 * @var int
45
	 */
46
	private $_votes;
47
48
	public function getDisplayName()
49
	{
50
		return $this->label.' ('.$this->year.')';
51
	}
52
	
53
	/**
54
	 * @return int the vote count
55
	 */
56
	public function getVotes()
57
	{
58
		return $this->_votes;
59
	}
60
61
	/**
62
	 * Setter for votes. The value returned from the API is a string which 
63
	 * we'll convert to an integer.
64
	 * @param string $votes
65
	 */
66
	public function setVotes($votes)
67
	{
68
		$this->_votes = (int)str_replace(',', '', $votes);
69
	}
70
	
71
	/**
72
	 * @return string the first credited director, or an empty string
73
	 */
74
	public function getDirector()
75
	{
76
		if ($this->director === null || count($this->director) === 0)
77
			return '';
78
		else
79
			return $this->director[0];
80
	}
81
82
	/**
83
	 * @return string the URL to the movie's IMDb page
84
	 */
85
	public function getIMDbUrl()
86
	{
87
		return 'http://www.imdb.com/title/'.$this->imdbnumber.'/';
88
	}
89
90
	/**
91
	 * @return string
92
	 */
93
	public function getDateAdded()
94
	{
95
		return $this->dateadded;
96
	}
97
98
	public function getArtwork()
99
	{
100
		if (isset($this->art->poster)) {
101
			return $this->art->poster;
102
		}
103
104
		return parent::getArtwork();
105
	}
106
}
107