MediaFlagAspect   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 15
c 2
b 0
f 0
dl 0
loc 24
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A getIcon() 0 21 3
1
<?php
2
3
/**
4
 * Aspect ratio flag
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 MediaFlagAspect extends MediaFlagStreamDetails
11
{
12
13
	protected function getIcon()
14
	{
15
		$aspect = $this->video->width / $this->video->height;
16
17
		// Map minimum aspect ratio to the corresponding icon.
18
		// Borrowed from https://github.com/xbmc/xbmc/blob/master/xbmc/utils/StreamDetails.cpp
19
		$map = array(
20
			'1.3499'=>'50px-1.33',
21
			'1.5080'=>'50px-1.37',
22
			'1.8147'=>'50px-1.66',
23
			'2.0174'=>'50px-1.85',
24
			'2.2738'=>'50px-2.20',
25
			'2.3749'=>'50px-2.35',
26
			'2.4739'=>'50px-2.40',
27
			'2.6529'=>'50px-2.55');
28
29
		foreach ($map as $ratio=> $icon)
30
			if ($aspect < $ratio)
31
				return $icon;
32
33
		return '50px-2.76';
34
	}
35
36
}