Add type-safe wrapper around MD_STD
This commit is contained in:
parent
bac86627e2
commit
25b3138a26
19
MD_STD.php
19
MD_STD.php
|
@ -284,6 +284,25 @@ class MD_STD {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Type-safe wrapper around filesize, if output is false, throws an error.
|
||||
*
|
||||
* @param string $filename File name.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public static function filesize(string $filename):int {
|
||||
|
||||
$output = filesize($filename);
|
||||
|
||||
if ($output === false) {
|
||||
throw new Exception("Cannot get filesize of file {$filename}");
|
||||
}
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Function human_filesize translates byte-level filesizes to human readable ones.
|
||||
* Thanks to Jeffrey Sambells http://jeffreysambells.com/2012/10/25/human-readable-filesize-php
|
||||
|
|
Loading…
Reference in New Issue
Block a user