Test Setup Failed
Push — test ( 3f4611...5d3f5c )
by Jonathan
03:36
created

Utils   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 22
rs 10
c 1
b 0
f 0
wmc 1
lcom 0
cbo 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getHumanReadableBytes() 0 12 1
1
<?php
2
3
namespace Kint;
4
5
class Utils
6
{
7
    /**
8
     * Turns a byte value into a human-readable representation.
9
     *
10
     * @param int $value Amount of bytes
11
     *
12
     * @return [value, unit]        Human readable value and unit
0 ignored issues
show
Documentation introduced by
The doc-type value,">[value, could not be parsed: Unknown type name "[" at position 0. [(view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
13
     */
14
    public static function getHumanReadableBytes($value)
15
    {
16
        static $unit = array('B', 'KB', 'MB', 'GB', 'TB');
17
18
        $i = floor(log($value, 1024));
19
        $i = min($i, 4); // Only go up to TB
20
21
        return array(
22
            'value' => $value / pow(1024, $i),
23
            'unit' => $unit[$i],
24
        );
25
    }
26
}
27