Base   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getDisplayName() 0 3 1
A getId() 0 3 1
A getName() 0 3 1
A getArtwork() 0 3 1
A getIdField() 0 5 3
1
<?php
2
3
/**
4
 * Base class for all items fetched through the API.
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
abstract class Base extends CComponent implements ITypeaheadData
11
{
12
13
	/**
14
	 * @var string
15
	 */
16
	public $label;
17
18
	/**
19
	 * @var string
20
	 */
21
	public $thumbnail;
22
23
	public function getName()
24
	{
25
		return $this->label;
26
	}
27
	
28
	/**
29
	 * Returns the name of the first field that ends with "id". This is needed 
30
	 * because all items from the XBMC API use different identifiers.
31
	 * @return string the name of the "id" field
32
	 */
33
	public function getIdField()
34
	{
35
		foreach (array_keys(get_object_vars($this)) as $property)
36
			if (substr($property, -2) === 'id')
37
				return $property;
38
	}
39
	
40
	/**
41
	 * @return string ID of this item
42
	 */
43
	public function getId()
44
	{
45
		return $this->{$this->getIdField()};
46
	}
47
48
	/**
49
	 * @return string the display name of this item
50
	 */
51
	public function getDisplayName()
52
	{
53
		return $this->label;
54
	}
55
56
	/**
57
	 * @return string the artwork for this item
58
	 */
59
	public function getArtwork()
60
	{
61
		return $this->thumbnail;
62
	}
63
64
}
65