for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Simple utility class to format times and sizes
*/
namespace Rocket\Utilities;
class Format
{
* Get file size with correct extension
*
* @param int $bytes
* @return string
public static function getReadableSize($bytes)
$unit = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
$exp = floor(log($bytes, 1024)) | 0;
return round($bytes / (pow(1024, $exp)), 2) . " $unit[$exp]";
}
* Format time
* @param int $time
public static function getReadableTime($time)
if ($time < 1000) {
return "{$time}ms";
$prefix = '';
if ($time >= 60000) {
$prefix = floor($time / 60000) . 'm ';
$time = $time % 60000;
return $prefix . number_format((float) ($time / 1000), 3, '.', '') . 's';