summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/Helper/TextHelper.php4
-rw-r--r--tests/units/Helper/TextHelperTest.php1
2 files changed, 5 insertions, 0 deletions
diff --git a/app/Helper/TextHelper.php b/app/Helper/TextHelper.php
index 654eb171..66583cd1 100644
--- a/app/Helper/TextHelper.php
+++ b/app/Helper/TextHelper.php
@@ -59,6 +59,10 @@ class TextHelper extends Base
*/
public function bytes($size, $precision = 2)
{
+ if ($size == 0) {
+ return 0;
+ }
+
$base = log($size) / log(1024);
$suffixes = array('', 'k', 'M', 'G', 'T');
diff --git a/tests/units/Helper/TextHelperTest.php b/tests/units/Helper/TextHelperTest.php
index 5c8a10f6..35ed5a1e 100644
--- a/tests/units/Helper/TextHelperTest.php
+++ b/tests/units/Helper/TextHelperTest.php
@@ -107,6 +107,7 @@ class TextHelperTest extends Base
{
$textHelper = new TextHelper($this->container);
+ $this->assertEquals('0', $textHelper->bytes(0));
$this->assertEquals('1k', $textHelper->bytes(1024));
$this->assertEquals('33.71k', $textHelper->bytes(34520));
}