private function saveConfigToCache($config)
    {
        if (!is_dir($cacheDir = dirname($this->cachedFile))) {
            if (!make_dir($cacheDir, 0775)) {
                throw new RuntimeException(sprintf('Configuration Loader was not able to create directory "%s"', $cacheDir)); // @codeCoverageIgnore
            }
        }

        if (file_exists($this->cachedFile)) {
            @unlink($this->cachedFile); // so we will to be the owner at the new file
        }

        if (file_put_contents($this->cachedFile, '<?php return ' . var_export($config->get(), true) . ';' . PHP_EOL, LOCK_EX) === false) {
            throw new RuntimeException(sprintf('Configuration Loader was not able to save cached file "%s"', $this->cachedFile)); // @codeCoverageIgnore
        }

        @chmod($this->cachedFile, 0664);

        $time = max(filemtime($this->configPath), filemtime($this->envFile));
        if (!@touch($this->cachedFile, $time)) {
            throw new RuntimeException(sprintf('Configuration Loader was not able to modify time of cached file "%s"', $this->cachedFile)); // @codeCoverageIgnore
        }
    }