Do not try to format size if 0
This commit is contained in:
parent
fe3ac50aca
commit
6307070507
|
|
@ -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');
|
||||
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue