XSPFPlaylist::__toString()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 16
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 4
Bugs 1 Features 1
Metric Value
cc 3
eloc 7
c 4
b 1
f 1
nc 3
nop 0
dl 0
loc 16
rs 10
1
<?php
2
3
/**
4
 * Represents an XSPF playlist
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 XSPFPlaylist extends Playlist
11
{
12
13
	public function __toString()
14
	{
15
		$playlist = new \Jalle19\xsphpf\Playlist();
16
17
		foreach ($this->_items as $item)
18
		{
19
			// Runtime should be in milliseconds
20
			$track = new \Jalle19\xsphpf\Track($item->location, $item->title, $item->runtime * 1000);
21
			
22
			if ($item->image)
23
				$track->setImage($item->image);
24
25
			$playlist->addTrack($track);
26
		}
27
28
		return $playlist->__toString();
29
	}
30
31
	public function getExtension()
32
	{
33
		return 'xspf';
34
	}
35
36
	public function getMIMEType()
37
	{
38
		return 'application/xspf+xml';
39
	}
40
41
}
42