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

PlaylistItem::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 6
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 13
rs 10
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