src/Environaut/Command/CheckCommand.php
protected function getLoadedCache()
    {
        if ($this->input->getOption('no-cache')) {
            $this->readonly_cache = new ReadOnlyCache();
            return $this->readonly_cache;
        }

        $cache_implementor = $this->config->getReadOnlyCacheImplementor();
        $cache = new $cache_implementor();

        if (!$cache instanceof IReadOnlyCache) {
            throw new \InvalidArgumentException(
                'The given cache class "' . $cache_implementor . '" does not implement IReadOnlyCache.'
            );
        }

        $cache_params = new Parameters($this->config->get('cache', array()));
        $cache_location = $this->input->getOption('cache-location');

        $this->readonly_cache = $cache;
        $this->readonly_cache->setParameters($cache_params);
        if (!empty($cache_location)) {
            if (is_readable($cache_location)) {
                $this->readonly_cache->setLocation($cache_location);
            } else {
                $this->output->writeln(
                    '<comment>Given cache location could not be read. ' .
                    'Using fallback from config or default location.</comment>'
                );
            }
        }

        $this->readonly_cache->load();

        $this->output->writeln(
            '<info>Loaded <comment>' . count($cache->getAll()) . '</comment> cached settings from:</info> ' .
            $cache->getLocation()
        );
        $this->output->writeln('');

        return $this->readonly_cache;
    }
protected function getLoadedCache()
    {
        if ($this->input->getOption('no-cache')) {
            $this->readonly_cache = new ReadOnlyCache();
            return $this->readonly_cache;
        }

        $cache_implementor = $this->config->getReadOnlyCacheImplementor();
        $cache = new $cache_implementor();

        if (!$cache instanceof IReadOnlyCache) {
            throw new \InvalidArgumentException(
                'The given cache class "' . $cache_implementor . '" does not implement IReadOnlyCache.'
            );
        }

        $cache_params = new Parameters($this->config->get('cache', array()));
        $cache_location = $this->input->getOption('cache-location');

        $this->readonly_cache = $cache;
        $this->readonly_cache->setParameters($cache_params);
        if (!empty($cache_location)) {
            if (is_readable($cache_location)) {
                $this->readonly_cache->setLocation($cache_location);
            } else {
                $this->output->writeln(
                    '<comment>Given cache location could not be read. ' .
                    'Using fallback from config or default location.</comment>'
                );
            }
        }

        $this->readonly_cache->load();

        $this->output->writeln(
            '<info>Loaded <comment>' . count($cache->getAll()) . '</comment> cached settings from:</info> ' .
            $cache->getLocation()
        );
        $this->output->writeln('');

        return $this->readonly_cache;
    }
Creates a cache instance and tries to load it according to command line argument or config.

The cache is used in the runner to allow checks to access old values that may already have
been configured and thus improve their flow and e.g. not ask values again or just confirm them.

@return IReadOnlyCache cache instance