Calculates the Directory based on a key

@param string $key
@return string
358366
protected function getDir($key)
    {
        $dir = sha1($key);
        $dir = substr($dir, 0, 3) . '/'
            . substr($dir, 3, 3) . '/';

        return $dir;
    }
27913
public function getDirective($key)
    {
        if (array_key_exists($key, $this->directives)) {
            return $this->directives[$key];
        }

        return null;
    }
1129840
protected function realizeDir($key)
    {
        $path = $this->getPath($key);

        if (!$this->files->exists($dir = dirname($path))) {
            $this->files->mkdir($dir);
        }

        return $path;
    }
876810
public function getKeyPath($key)
    {
        if (substr($key, 0, 1) !== '/') {
            $key = '/' . $key;
        }

        return rtrim('/' . $this->api_version . '/keys' . $this->root, '/') . $key;
    }
392064
protected function getPath(/*# string */ $key)/*# : string */
    {
        // get directory first
        if (($pos = strrpos($key, '/')) !== false) {
            $dir  = $this->dir_root . DIRECTORY_SEPARATOR .
                    substr($key, 0, $pos) . DIRECTORY_SEPARATOR;
            $key  = substr($key, $pos + 1);
        } else {
            $dir  = $this->dir_root . DIRECTORY_SEPARATOR;
        }

        // get file path
        if (is_callable($this->path_func)) {
            $func = $this->path_func;
            $file = $func($key);

        // hashed version
        } else {
            $file = $key ? $this->hashIt($key) : '';
        }

        return $dir . $file;
    }
925064
protected function getPath($key)
    {
        $parts = explode('/', $key);
        $path = substr(parent::getPath(array_shift($parts)), 0, -4);
        foreach ($parts as $part) {
            $path .= DIRECTORY_SEPARATOR.$this->sanitizeReadableFileName($part);
        }
        return $path.'.conf.php';
    }
974194
private function getHeader($key)
    {
        if (! $this->headers) {
            $this->headers = $this->getHeaders();
        }
        if (array_key_exists($key, $this->headers)) {
            //if redirects encountered, return the final values
            if (is_array($this->headers[$key])) {
                return end($this->headers[$key]);
            } else {
                return $this->headers[$key];
            }
        }
    }
1207596
protected function cacheFile(string $key): string
    {
        return $this->path . '/' . $this->prefix . $key . $this->extension;
    }
395500
public function files(...$key)
    {
        $files = $this->files;
        while ($key) {
            $files = $files[array_shift($key)] ?? null;
        }

        return $files;
    }
1008553
public function getFile($key)
    {
        $key = str_replace($this->illegalChars, '_', $this->namespace . $key);
        return $this->dir . '/' . $key . '.' . $this->ext;
    }
824017
protected function getKeyPath($key)
    {
        if (empty($this->options['parents'])) {
            return $key;
        }

        if (is_string($this->options['parents'])) {
            $this->options['parents'] = explode('.', $this->options['parents']);
        }

        if (is_string($key)) {
            $key = explode('.', $key);
        }

        return array_merge((array) $this->options['parents'], (array) $key);
    }
576756
protected function _getFilePath($key) {
		if (substr($key, -5) === '.json') {
			$key = substr($key, 0, -5);
		}
		list($plugin, $key) = pluginSplit($key);
		$key .= '.json';

		if ($plugin) {
			$file = App::pluginPath($plugin) . 'Config' . DS . $key;
		} else {
			$file = $this->_path . $key;
		}

		return $file;
	}
500987
public function delete($key)
    {
        if ($this->isDirectory($key)) {
            return rmdir($this->computePath($key));
        }

        return unlink($this->computePath($key));
    }
1192877
public function &offsetGet($key)
    {
        if (!isset($this->storage[$key])) {
            $this->storage[$key] = null;
        }

        return $this->storage[$key];
    }
777751
private function getFileNameForKey($key)
    {
        return $this->getDir().strtr($this->format, ['%key%' => $key, '%env%' => $this->environment]);
    }
1186861
public function get($key)
    {
        $md5 = md5($key);
        $folderPath = $this->getFolderPathFromMd5($md5);
        $path = $this->path . self::DS . $folderPath . self::DS . $this->prefix . $md5;
        if (!file_exists($path) || !is_readable($path)) {
            return false;
        }

        $content = file_get_contents($path);
        if (!$content) {
            return false;
        }

        $pieces = explode(PHP_EOL, $content);
        if (!is_array($pieces) || !is_numeric($pieces[0])) {
            unlink($path);
            return false;
        }

        $val = @unserialize($pieces[1]);
        if ($val === false) {
            $this->remove($key);
            return false;
        }

        return $val;
    }
456873
private function getFilePath($key)
    {
        if (!preg_match('|^[a-zA-Z0-9_\.! ]+$|', $key)) {
            throw new InvalidArgumentException(sprintf('Invalid key "%s". Valid filenames must match [a-zA-Z0-9_\.! ].', $key));
        }

        return sprintf('%s/%s', $this->folder, $key);
    }