Add type-safe wrapper around realpath
This commit is contained in:
1 parent
f44fd251e1
commit
079786e42d
1 file changed
+16
+16
@@ -34,6 +34,22 @@ public static function file_get_contents(string $filename):string {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
* Gets contents of a folder.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in new issue
Block a user