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

PLSPlaylist   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getExtension() 0 3 1
A __toString() 0 23 2
A getMIMEType() 0 3 1
1
<?php
2
3
/**
4
 * Represents an PLS 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 PLSPlaylist extends Playlist
11
{
12
13
	public function __toString()
14
	{
15
		ob_start();
16
17
		// Header
18
		echo '[playlist]'.PHP_EOL;
19
20
		// Items
21
		$i = 1;
22
		foreach ($this->_items as $item)
23
		{
24
			echo "File$i=".$item->location.PHP_EOL;
25
			echo "Title$i=".$item->title.PHP_EOL;
26
			echo "Length$i=".$item->runtime.PHP_EOL;
27
28
			++$i;
29
		}
30
31
		// Footer
32
		echo "NumberOfEntries=$i".PHP_EOL;
33
		echo 'Version=2'.PHP_EOL;
34
35
		return ob_get_clean();
36
	}
37
38
	public function getExtension()
39
	{
40
		return 'pls';
41
	}
42
43
	public function getMIMEType()
44
	{
45
		return 'audio/x-scpls';
46
	}
47
48
}
49