summaryrefslogtreecommitdiff
path: root/src/Filesystem/CreateFile.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Filesystem/CreateFile.php')
-rw-r--r--src/Filesystem/CreateFile.php65
1 files changed, 0 insertions, 65 deletions
diff --git a/src/Filesystem/CreateFile.php b/src/Filesystem/CreateFile.php
deleted file mode 100644
index ce9537f..0000000
--- a/src/Filesystem/CreateFile.php
+++ /dev/null
@@ -1,65 +0,0 @@
-<?php
-
-namespace App\Filesystem;
-
-use App\Task\TaskInterface;
-
-/**
- * Class to create a new file
- *
- * @author Phil Burton <phil@d3r.com>
- */
-class CreateFile implements TaskInterface
-{
- /**
- * Name of file to create
- *
- * @var string
- */
- protected $filename;
-
- /**
- * File contents to write
- *
- * @var string
- */
- protected $contents;
-
- /**
- * Check if the file already exists
- *
- * @param string $filename
- * @author Phil Burton <phil@d3r.com>
- */
- 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 file at: ' . $filename);
- }
-
- if (file_exists($filename)) {
- throw new \Exception('File already exists at: ' . $filename);
- }
- }
-
- /**
- * Create the new file
- *
- * @author Phil Burton <phil@d3r.com>
- */
- public function execute()
- {
- touch($this->filename);
-
- $contents = $this->contents;
- if ($contents) {
- file_put_contents($this->filename, $contents);
- }
- }
-}