Skip to content

Commit 151417c

Browse files
committed
Emergency response to external rugpull
Respect your semver, kids!
1 parent 9c4c463 commit 151417c

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/AbstractEvictStrategy.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,10 @@ abstract public function execute();
4242
*/
4343
protected function bytesToHuman(int $bytes): string
4444
{
45-
// in case the library broke, we can refer to this link: https://stackoverflow.com/questions/15188033/human-readable-file-size
46-
$formatter = new ByteFormatter();
47-
return $formatter->format($bytes);
45+
// the guy did a rugpull; the link turned out to be very handy.
46+
// see https://stackoverflow.com/questions/15188033/human-readable-file-size
47+
$units = ['B', 'KB', 'MB', 'GB', 'TB', 'PB'];
48+
for ($i = 0; $bytes > 1024; $i++) $bytes /= 1024;
49+
return round($bytes, 2) . ' ' . $units[$i];
4850
}
4951
}

0 commit comments

Comments
 (0)