Doctrine\Common\Cache\FileCache::writeFile PHP Method

writeFile() protected method

Writes a string content to file in an atomic way.
protected writeFile ( string $filename, string $content ) : boolean
$filename string Path to the file where to write the data.
$content string The content to write
return boolean TRUE on success, FALSE if path cannot be created, if path is not writable or an any other error.
    protected function writeFile($filename, $content)
    {
        $filepath = pathinfo($filename, PATHINFO_DIRNAME);
        if (!$this->createPathIfNeeded($filepath)) {
            return false;
        }
        if (!is_writable($filepath)) {
            return false;
        }
        $tmpFile = tempnam($filepath, 'swap');
        @chmod($tmpFile, 0666 & ~$this->umask);
        if (file_put_contents($tmpFile, $content) !== false) {
            if (@rename($tmpFile, $filename)) {
                return true;
            }
            @unlink($tmpFile);
        }
        return false;
    }