From 47b154758e789e75ec597d88540cdb7f4e352225 Mon Sep 17 00:00:00 2001 From: Fbenas Date: Tue, 22 Aug 2017 01:07:51 +0100 Subject: Make sure we write the nginx conf --- src/Filesystem/CreateFile.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/Filesystem') diff --git a/src/Filesystem/CreateFile.php b/src/Filesystem/CreateFile.php index 08ba0db..93c66a6 100644 --- a/src/Filesystem/CreateFile.php +++ b/src/Filesystem/CreateFile.php @@ -18,16 +18,22 @@ class CreateFile protected $filename; + protected $contents; + /** * Check if the file already exists * * @param string $filename * @author Phil Burton */ - public function __construct(string $filename) + public function __construct(string $filename, $contents = false) { $this->filename = $filename; + if ($contents) { + $this->contents = $contents; + } + if (!is_writable(dirname($filename))) { throw new \Exception('Cannot create ' . $this->thing . ' at: ' . $filename); } @@ -45,5 +51,10 @@ class CreateFile public function execute() { touch($this->filename); + + $contents = $this->contents; + if ($contents) { + file_put_contents($this->filename, $contents); + } } } -- cgit v1.2.3