mirror of
https://github.com/notf0und/SGS
synced 2026-07-18 02:31:08 +00:00
* Fix CI/CD php version
* Add Pint * Format code
This commit is contained in:
parent
0993bfa666
commit
bae79d68ab
@@ -5,6 +5,7 @@ namespace App\Helpers;
|
||||
class FileSize
|
||||
{
|
||||
private const UNITS = ['', 'K', 'M', 'G', 'T'];
|
||||
|
||||
private const THRESHOLD = 1024;
|
||||
|
||||
/**
|
||||
@@ -18,10 +19,10 @@ class FileSize
|
||||
|
||||
$unitIndex = (int) floor(log($bytes, self::THRESHOLD));
|
||||
$unitIndex = min($unitIndex, count(self::UNITS) - 1);
|
||||
|
||||
|
||||
$size = $bytes / pow(self::THRESHOLD, $unitIndex);
|
||||
$decimals = $unitIndex === 0 ? 0 : 2;
|
||||
|
||||
return number_format($size, $decimals, '.', '') . self::UNITS[$unitIndex];
|
||||
return number_format($size, $decimals, '.', '').self::UNITS[$unitIndex];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user