@@ 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 |
@@ 744-776 (lines=33) @@ | ||
741 | * @param string $value String of size |
|
742 | * @return integer |
|
743 | */ |
|
744 | public static function parseSize($value) |
|
745 | { |
|
746 | $l = substr($value, -1); |
|
747 | ||
748 | if ($l === 'b' || $l === 'B') { |
|
749 | return ((int)substr($value, 0, -1)); |
|
750 | } |
|
751 | ||
752 | if ($l === 'k') { |
|
753 | return ((int)substr($value, 0, -1) * 1000); |
|
754 | } |
|
755 | ||
756 | if ($l === 'K') { |
|
757 | return ((int)substr($value, 0, -1) * 1024); |
|
758 | } |
|
759 | ||
760 | if ($l === 'm') { |
|
761 | return ((int)substr($value, 0, -1) * 1000 * 1000); |
|
762 | } |
|
763 | ||
764 | if ($l === 'M') { |
|
765 | return ((int)substr($value, 0, -1) * 1024 * 1024); |
|
766 | } |
|
767 | ||
768 | if ($l === 'g') { |
|
769 | return ((int)substr($value, 0, -1) * 1000 * 1000 * 1000); |
|
770 | } |
|
771 | ||
772 | if ($l === 'G') { |
|
773 | return ((int)substr($value, 0, -1) * 1024 * 1024 * 1024); |
|
774 | } |
|
775 | ||
776 | return (int)$value; |
|
777 | } |
|
778 | ||
779 | /** |