mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-07-02 10:04:39 +02:00
fix: php notice in eztvbridge (#2998)
* fix: php notice in eztvbridge Fixes Undefined property: stdClass::$torrents * lint
This commit is contained in:
parent
b8f73618c1
commit
57d5aa45f7
3 changed files with 59 additions and 52 deletions
|
@ -136,3 +136,18 @@ function parse_mime_type($url)
|
|||
|
||||
return 'application/octet-stream';
|
||||
}
|
||||
|
||||
/**
|
||||
* https://stackoverflow.com/a/2510459
|
||||
*/
|
||||
function format_bytes(int $bytes, $precision = 2)
|
||||
{
|
||||
$units = ['B', 'KB', 'MB', 'GB', 'TB'];
|
||||
|
||||
$bytes = max($bytes, 0);
|
||||
$pow = floor(($bytes ? log($bytes) : 0) / log(1024));
|
||||
$pow = min($pow, count($units) - 1);
|
||||
$bytes /= pow(1024, $pow);
|
||||
|
||||
return round($bytes, $precision) . ' ' . $units[$pow];
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue