Passed
Push — master ( 6436ae...468f1f )
by Goffy
29s queued 11s
created

tdmdownloadsReturnBytes()   B

Complexity

Conditions 7
Paths 7

Size

Total Lines 14
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 7
eloc 12
nc 7
nop 1
dl 0
loc 14
rs 8.8333
c 0
b 0
f 0
1
<?php
2
/**
3
 * tdmdownloads
4
 *
5
 * You may not change or alter any portion of this comment or credits
6
 * of supporting developers from this source code or any supporting source code
7
 * which is considered copyrighted (c) material of the original comment or credit authors.
8
 * This program is distributed in the hope that it will be useful,
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
 *
12
 * @copyright   Gregory Mage (Aka Mage)
13
 * @license     GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
14
 * @author      Gregory Mage (Aka Mage)
15
 */
16
17
/**
18
 * @param $val
19
 * @return float|int
20
 */
21
function tdmdownloadsReturnBytes($val)
22
{
23
    switch (mb_substr($val, -1)) {
24
        case 'K':
25
        case 'k':
26
            return (int)$val * 1024;
27
        case 'M':
28
        case 'm':
29
            return (int)$val * 1048576;
30
        case 'G':
31
        case 'g':
32
            return (int)$val * 1073741824;
33
        default:
34
            return $val;
35
    }
36
}