ByteFormat
in package
FinalYes
Table of Contents
Constants
- DECIMAL_DEFAULT = true
- Whether the default behaviour for the format function is decimal (power of 10) or not (power of 2).
Methods
- format() : string
- Formats a raw amount of bytes as a human readable string.
- formatBinary() : string
- Formats a raw amount of bytes as a human readable string in the power of 2 (e.g. MiB).
- formatDecimal() : string
- Formats a raw amount of bytes as a human readable string in the power of 10 (e.g. MB).
Constants
DECIMAL_DEFAULT
Whether the default behaviour for the format function is decimal (power of 10) or not (power of 2).
public
bool
DECIMAL_DEFAULT
= true
Methods
format()
Formats a raw amount of bytes as a human readable string.
public
static format(int $bytes[, bool $decimal = self::DECIMAL_DEFAULT ]) : string
Parameters
- $bytes : int
-
Number of bytes.
- $decimal : bool = self::DECIMAL_DEFAULT
-
Whether format as a power of 10 (e.g. MB) or a power of 2 (e.g. MiB).
Return values
string —Formatted byte string.
formatBinary()
Formats a raw amount of bytes as a human readable string in the power of 2 (e.g. MiB).
public
static formatBinary(int $bytes) : string
Parameters
- $bytes : int
-
Number of bytes.
Return values
string —Formatted byte string.
formatDecimal()
Formats a raw amount of bytes as a human readable string in the power of 10 (e.g. MB).
public
static formatDecimal(int $bytes) : string
Parameters
- $bytes : int
-
Number of bytes.
Return values
string —Formatted byte string.