From 3ba8b0462c682a66eda0120c0ebbc37ee740e39c Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Fri, 11 Aug 2017 22:29:43 -0700 Subject: Fix parsing issue in phpToBytes() --- app/Helper/TextHelper.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'app/Helper') diff --git a/app/Helper/TextHelper.php b/app/Helper/TextHelper.php index 89c1a8f3..698bef6d 100644 --- a/app/Helper/TextHelper.php +++ b/app/Helper/TextHelper.php @@ -90,19 +90,19 @@ class TextHelper extends Base */ public function phpToBytes($val) { - $val = trim($val); - $last = strtolower($val[strlen($val)-1]); + $size = (int) substr($val, 0, -1); + $last = strtolower(substr($val, -1)); switch ($last) { case 'g': - $val *= 1024; + $size *= 1024; case 'm': - $val *= 1024; + $size *= 1024; case 'k': - $val *= 1024; + $size *= 1024; } - return $val; + return $size; } /** -- cgit v1.2.3