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

PlaylistItem   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 11
c 1
b 0
f 1
dl 0
loc 40
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 13 1
1
<?php
2
3
/**
4
 * Represents a playlist item
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 PlaylistItem
11
{
12
13
	/**
14
	 * @var string the item title
15
	 */
16
	public $title;
17
18
	/**
19
	 * @var string the item location (the URL)
20
	 */
21
	public $location;
22
23
	/**
24
	 * @var int the item runtime (in seconds)
25
	 */
26
	public $runtime;
27
28
	/**
29
	 * @var string the URL to the item image
30
	 */
31
	public $image;
32
	
33
	/**
34
	 * Class constructor
35
	 * @param ItemLink $itemLink
36
	 */
37
	public function __construct($itemLink)
38
	{
39
		$this->title = $itemLink->name;
40
		$this->location = $itemLink->url;
41
		
42
		$media = $itemLink->media;
43
		
44
		// Set runtime
45
		$this->runtime = $media->runtime;
46
		
47
		// Generate a link to the artwork
48
		$thumbnail = ThumbnailFactory::create($media->getArtwork(), Thumbnail::SIZE_LARGE);
49
		$this->image = Yii::app()->request->hostInfo.$thumbnail->getUrl();
50
	}
51
52
}
53