Passed
Push — master ( c28376...9b6cf0 )
by Georgi
07:09
created

Utils   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
dl 0
loc 11
rs 10
c 1
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A bytesToHuman() 0 9 2
1
<?php
2
3
namespace Epesi\Core\Helpers;
4
5
class Utils
6
{
7
    public static function bytesToHuman($bytes)
8
    {
9
        $units = [__('B'), __('KiB'), __('MiB'), __('GiB'), __('TiB'), __('PiB')];
10
11
        for ($i = 0; $bytes > 1024; $i++) {
12
            $bytes /= 1024;
13
        }
14
15
        return round($bytes, 2) . ' ' . $units[$i];
0 ignored issues
show
Bug introduced by
Are you sure $units[$i] of type array|string can be used in concatenation? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

15
        return round($bytes, 2) . ' ' . /** @scrutinizer ignore-type */ $units[$i];
Loading history...
16
    }
17
}