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

MediaFlag   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 0
dl 0
loc 39
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A run() 0 6 2
A init() 0 3 1
1
<?php
2
3
/**
4
 * Base class for media flag widgets
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 MediaFlag extends CWidget
11
{
12
13
	/**
14
	 * @var string the media file name
15
	 */
16
	public $file;
17
18
	/**
19
	 * @var string the base URL to the flag icons
20
	 */
21
	private $_iconBaseDir;
22
23
	/**
24
	 * Initializes the widget
25
	 */
26
	public function init()
27
	{
28
		$this->_iconBaseDir = Yii::app()->baseUrl.'/images/xbmc-media-flags';
29
	}
30
31
	/**
32
	 * Runs the widget. If an icon can be determined it will be rendered.
33
	 */
34
	public function run()
35
	{
36
		$icon = $this->getIcon();
37
38
		if ($icon !== false)
39
			echo CHtml::image($this->_iconBaseDir.'/'.$icon.'.png');
40
	}
41
42
	/**
43
	 * Returns the name of the icon file that should be displayed, without the 
44
	 * file extension, e.g. "50px-720". If no icon can be determined, false is returned
45
	 * @return string|false the icon name
46
	 */
47
	abstract protected function getIcon();
48
}
49