private function saveFile($file, $content, $time)
    {
        // create directory if not exists
        if (!is_dir($dir = dirname($file))) {
            // @codeCoverageIgnoreStart
            if (!make_dir($dir, 0775)) {
                throw new RuntimeException(sprintf('View Template Engine was not able to create directory "%s"', $dir)); // @codeCoverageIgnore
            }
            // @codeCoverageIgnoreEnd
        } // @codeCoverageIgnore

        // save file
        if (file_exists($file)) {
            unlink($file); // so we will to be the owner at the new file
        }

        if (file_put_contents($file, $content, LOCK_EX) === false) {
            throw new RuntimeException(sprintf('View Template Engine was not able to save file "%s"', $file)); // @codeCoverageIgnore
        }

        @chmod($file, 0664);

        // set file modification time
        if (!@touch($file, $time)) {
            throw new RuntimeException(sprintf('View Template Engine was not able to modify time of file "%s"', $file)); // @codeCoverageIgnore
        }
    }