@@ 22-54 (lines=33) @@ | ||
19 | * @param $value |
|
20 | * @return int |
|
21 | */ |
|
22 | public static function HumanToPlain($value) |
|
23 | { |
|
24 | $l = substr($value, -1); |
|
25 | ||
26 | if ($l === 'b' || $l === 'B') { |
|
27 | return ((int)substr($value, 0, -1)); |
|
28 | } |
|
29 | ||
30 | if ($l === 'k') { |
|
31 | return ((int)substr($value, 0, -1) * 1000); |
|
32 | } |
|
33 | ||
34 | if ($l === 'K') { |
|
35 | return ((int)substr($value, 0, -1) * 1024); |
|
36 | } |
|
37 | ||
38 | if ($l === 'm') { |
|
39 | return ((int)substr($value, 0, -1) * 1000 * 1000); |
|
40 | } |
|
41 | ||
42 | if ($l === 'M') { |
|
43 | return ((int)substr($value, 0, -1) * 1024 * 1024); |
|
44 | } |
|
45 | ||
46 | if ($l === 'g') { |
|
47 | return ((int)substr($value, 0, -1) * 1000 * 1000 * 1000); |
|
48 | } |
|
49 | ||
50 | if ($l === 'G') { |
|
51 | return ((int)substr($value, 0, -1) * 1024 * 1024 * 1024); |
|
52 | } |
|
53 | ||
54 | return (int)$value; |
|
55 | } |
|
56 | } |
|
57 |
@@ 731-763 (lines=33) @@ | ||
728 | * @param string $value String of size |
|
729 | * @return integer |
|
730 | */ |
|
731 | public static function parseSize($value) |
|
732 | { |
|
733 | $l = substr($value, -1); |
|
734 | ||
735 | if ($l === 'b' || $l === 'B') { |
|
736 | return ((int)substr($value, 0, -1)); |
|
737 | } |
|
738 | ||
739 | if ($l === 'k') { |
|
740 | return ((int)substr($value, 0, -1) * 1000); |
|
741 | } |
|
742 | ||
743 | if ($l === 'K') { |
|
744 | return ((int)substr($value, 0, -1) * 1024); |
|
745 | } |
|
746 | ||
747 | if ($l === 'm') { |
|
748 | return ((int)substr($value, 0, -1) * 1000 * 1000); |
|
749 | } |
|
750 | ||
751 | if ($l === 'M') { |
|
752 | return ((int)substr($value, 0, -1) * 1024 * 1024); |
|
753 | } |
|
754 | ||
755 | if ($l === 'g') { |
|
756 | return ((int)substr($value, 0, -1) * 1000 * 1000 * 1000); |
|
757 | } |
|
758 | ||
759 | if ($l === 'G') { |
|
760 | return ((int)substr($value, 0, -1) * 1024 * 1024 * 1024); |
|
761 | } |
|
762 | ||
763 | return (int)$value; |
|
764 | } |
|
765 | ||
766 | /** |