File: /var/www/vhost/disk-apps/magento.bikenow.co/vendor/webimpress/safe-writer/README.md
# Webimpress Safe Writer
[](https://github.com/webimpress/safe-writer/actions/workflows/phpunit.yml)
[](https://github.com/webimpress/safe-writer/actions/workflows/phpcs.yml)
[](https://github.com/webimpress/safe-writer/actions/workflows/static-analysis.yml)
[](https://coveralls.io/github/webimpress/safe-writer?branch=master)
Write files safely to avoid race conditions when
the same file is written multiple times in a short time period.
## Installation
Using composer:
```console
$ composer require webimpress/safe-writer
```
## Usage
```php
use Webimpress\SafeWriter\FileWriter;
$targetFile = __DIR__ . '/target-file.php';
$content = "<?php\nreturn " . var_export($data, true) . ';';
FileWriter::writeFile($targetFile, $content);
```
If something goes wrong exception (instance of `Webimpress\SafeWriter\Exception\ExceptionInterface`)
will be thrown.