| @@ 20-52 (lines=33) @@ | ||
| 17 | * @param $value |
|
| 18 | * @return int |
|
| 19 | */ |
|
| 20 | public static function humanToPlain($value) |
|
| 21 | { |
|
| 22 | $l = substr($value, -1); |
|
| 23 | ||
| 24 | if ($l === 'b' || $l === 'B') { |
|
| 25 | return ((int)substr($value, 0, -1)); |
|
| 26 | } |
|
| 27 | ||
| 28 | if ($l === 'k') { |
|
| 29 | return ((int)substr($value, 0, -1) * 1000); |
|
| 30 | } |
|
| 31 | ||
| 32 | if ($l === 'K') { |
|
| 33 | return ((int)substr($value, 0, -1) * 1024); |
|
| 34 | } |
|
| 35 | ||
| 36 | if ($l === 'm') { |
|
| 37 | return ((int)substr($value, 0, -1) * 1000 * 1000); |
|
| 38 | } |
|
| 39 | ||
| 40 | if ($l === 'M') { |
|
| 41 | return ((int)substr($value, 0, -1) * 1024 * 1024); |
|
| 42 | } |
|
| 43 | ||
| 44 | if ($l === 'g') { |
|
| 45 | return ((int)substr($value, 0, -1) * 1000 * 1000 * 1000); |
|
| 46 | } |
|
| 47 | ||
| 48 | if ($l === 'G') { |
|
| 49 | return ((int)substr($value, 0, -1) * 1024 * 1024 * 1024); |
|
| 50 | } |
|
| 51 | ||
| 52 | return (int)$value; |
|
| 53 | } |
|
| 54 | } |
|
| 55 | ||
| @@ 742-774 (lines=33) @@ | ||
| 739 | * @param string $value String of size |
|
| 740 | * @return integer |
|
| 741 | */ |
|
| 742 | public static function parseSize($value) |
|
| 743 | { |
|
| 744 | $l = substr($value, -1); |
|
| 745 | ||
| 746 | if ($l === 'b' || $l === 'B') { |
|
| 747 | return ((int)substr($value, 0, -1)); |
|
| 748 | } |
|
| 749 | ||
| 750 | if ($l === 'k') { |
|
| 751 | return ((int)substr($value, 0, -1) * 1000); |
|
| 752 | } |
|
| 753 | ||
| 754 | if ($l === 'K') { |
|
| 755 | return ((int)substr($value, 0, -1) * 1024); |
|
| 756 | } |
|
| 757 | ||
| 758 | if ($l === 'm') { |
|
| 759 | return ((int)substr($value, 0, -1) * 1000 * 1000); |
|
| 760 | } |
|
| 761 | ||
| 762 | if ($l === 'M') { |
|
| 763 | return ((int)substr($value, 0, -1) * 1024 * 1024); |
|
| 764 | } |
|
| 765 | ||
| 766 | if ($l === 'g') { |
|
| 767 | return ((int)substr($value, 0, -1) * 1000 * 1000 * 1000); |
|
| 768 | } |
|
| 769 | ||
| 770 | if ($l === 'G') { |
|
| 771 | return ((int)substr($value, 0, -1) * 1024 * 1024 * 1024); |
|
| 772 | } |
|
| 773 | ||
| 774 | return (int)$value; |
|
| 775 | } |
|
| 776 | ||
| 777 | /** |
|