Add type-safe wrapper around realpath
This commit is contained in:
parent
f44fd251e1
commit
079786e42d
16
MD_STD.php
16
MD_STD.php
|
@ -34,6 +34,22 @@ class MD_STD {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the real path of a relative file path. Throws an error rather than
|
||||
* returning the default false.
|
||||
*
|
||||
* @param string $path File path to convert.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function realpath(string $path):string {
|
||||
|
||||
$output = realpath($path);
|
||||
if (!is_string($output)) throw new MDFileDoesNotExist("The file {$path} does not exist or is not readable.");
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets contents of a folder.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue
Block a user