public static function removeDirectory($directoryPath, $contentOnly = false)
    {
        /*
         * Directory does not exist?
         * Nothing to do
         */
        if (!file_exists($directoryPath)) {
            return null;
        }

        /*
         * It's not a directory?
         * Let's treat it like file
         */
        if (!is_dir($directoryPath)) {
            return unlink($directoryPath);
        }

        foreach (scandir($directoryPath, SCANDIR_SORT_ASCENDING) as $item) {
            if ('.' === $item || '..' === $item) {
                continue;
            }

            if (!self::removeDirectory($directoryPath . DIRECTORY_SEPARATOR . $item)) {
                return false;
            }
        }

        // Directory should be removed too?
        if (!$contentOnly) {
            return rmdir($directoryPath);
        }

        return true;
    }