diff --git a/MD_STD.php b/MD_STD.php index 915d9bb..8123bba 100644 --- a/MD_STD.php +++ b/MD_STD.php @@ -62,7 +62,7 @@ final class MD_STD { * * @return void */ - public static function mkdir(string $pathname, int $mode = 0775, bool $recursive = false) { + public static function mkdir(string $pathname, int $mode = 0775, bool $recursive = false):void { if (\mkdir($pathname, $mode, $recursive) === false) { throw new Exception("Failed to create directory: $pathname"); @@ -70,6 +70,24 @@ final class MD_STD { } + /** + * Wrapper around unlink, that throws an exception if the file failed to be + * removed. + * + * @see https://www.php.net/manual/en/function.unlink.php + * + * @param string $filename File path. + * + * @return void + */ + public static function unlink(string $filename):void { + + if (\unlink($filename) === false) { + throw new Exception("Failed to delete: $filename"); + } + + } + /** * Gets contents of a folder. *