Composer\Satis\Builder\PackagesBuilder::writeToFile PHP Method

writeToFile() private method

Write to a file
private writeToFile ( string $path, string $contents )
$path string
$contents string
    private function writeToFile($path, $contents)
    {
        $dir = dirname($path);
        if (!is_dir($dir)) {
            if (file_exists($dir)) {
                throw new \UnexpectedValueException($dir . ' exists and is not a directory.');
            }
            if (!@mkdir($dir, 0777, true)) {
                throw new \UnexpectedValueException($dir . ' does not exist and could not be created.');
            }
        }
        $retries = 3;
        while ($retries--) {
            try {
                file_put_contents($path, $contents);
                break;
            } catch (\Exception $e) {
                if ($retries) {
                    usleep(500000);
                    continue;
                }
                throw $e;
            }
        }
    }