public static function deleteDirectoryContents(string $directoryPath)
    {
        $paths = scandir($directoryPath);
        if ($paths === false) {
            throw new \Exception("cannot list directory '{$directoryPath}'");
        }

        foreach ($paths as $path) {
            if ($path === '.' || $path === '..') {
                continue;
            }

            $fullPath = "{$directoryPath}/{$path}";

            if (is_dir($fullPath)) {
                self::deleteDirectoryContents($fullPath);//RECURSIVE CALL
                self::throwIfFalse(rmdir($fullPath), "cannot delete '{$fullPath}'", 1);
                continue;
            }

            self::throwIfFalse(unlink($fullPath), "cannot delete '{$fullPath}'", 2);
        }
    }