Add type-safe wrapper around realpath

This commit is contained in:
Joshua Ramon Enslin 2020-08-05 14:01:26 +02:00 committed by Stefan Rohde-Enslin
parent f44fd251e1
commit 079786e42d

View File

@ -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.
*