Completed
Push — master ( eef885...465d0c )
by
unknown
30:08 queued 12:49
created

size_util   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 27
rs 10
c 0
b 0
f 0
wmc 7
lcom 0
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A construct() 0 1 1
B convert_to() 0 15 6
1
<?php namespace eoxia;
2
3
if ( !defined( 'ABSPATH' ) ) exit;
4
5
/**
6
 * @author Jimmy Latour <[email protected]>
7
 * @version 1.0
8
 */
9
10
if ( ! class_exists( '\eoxia\size_util' ) ) {
11
	class size_util extends \eoxia\Singleton_Util {
12
		protected function construct() {}
13
14
		/**
15
	  * convert to - Convert format to "oc" or deconvert
16
	  *
17
	  * @param float $input
18
	  * @param string $format
19
	  * @param boolean $convert
20
	  * @return float|number
21
	  */
22
	  public function convert_to($input, $format, $convert = true) {
23
			if($format == 'oc')
24
				return $input;
25
			$multiple = 0;
26
			if($format == 'ko')
27
				$multiple = 1024;
28
			else if($format == 'mo')
29
				$multiple = 1048576;
30
			else if($format == 'go')
31
				$multiple = 1073741824;
32
			if($convert)
33
				return $input * $multiple;
34
			else
35
				return $input / $multiple;
36
		}
37
	}
38
39
}
40