public function getCacheDirectory()
    {
        if (!is_null($this->cacheDirectory)) {
            return $this->cacheDirectory;
        }
        if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
            if (!getenv('APPDATA')) {
                throw new RuntimeException(
                    'The APPDATA environment variable must be set for humbug.'
                );
            }
            $home = strtr(getenv('APPDATA'), '\\', '/') . '/Humbug';
        } else {
            if (!getenv('HOME')) {
                throw new RuntimeException(
                    'The HOME environment variable must be set for humbug.'
                );
            }
            $home = rtrim(getenv('HOME'), '/') . '/.humbug';
        }
        $cache = $home . '/cache';
        foreach ([$home, $cache] as $dir) {
            if (!is_dir($dir)) {
                mkdir($dir, 0777);
            }
        }
        file_put_contents($home . '/.htaccess', 'Deny from all');
        $this->cacheDirectory = $cache;
        return $cache;
    }