summaryrefslogtreecommitdiff
path: root/src/Filesystem/CreateFile.php
diff options
context:
space:
mode:
authorFbenas <philbeansburton@gmail.com>2017-08-22 01:07:51 +0100
committerFbenas <philbeansburton@gmail.com>2017-08-22 01:07:51 +0100
commit47b154758e789e75ec597d88540cdb7f4e352225 (patch)
tree3e8ec0a763e2d72534a54e177af292ee7100fbcf /src/Filesystem/CreateFile.php
parent3de70e73fb53ada12a4d7d332853253523720511 (diff)
Make sure we write the nginx conf
Diffstat (limited to 'src/Filesystem/CreateFile.php')
-rw-r--r--src/Filesystem/CreateFile.php13
1 files changed, 12 insertions, 1 deletions
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 <phil@d3r.com>
*/
- 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);
+ }
}
}