From 62146c4027e48cfbdb4f518de137de8430392e24 Mon Sep 17 00:00:00 2001 From: Fbenas Date: Sun, 18 Feb 2018 22:29:36 +0000 Subject: Split client and manager --- src/Filesystem/CreateDirectory.php | 49 ---------------------------- src/Filesystem/CreateFile.php | 65 -------------------------------------- 2 files changed, 114 deletions(-) delete mode 100644 src/Filesystem/CreateDirectory.php delete mode 100644 src/Filesystem/CreateFile.php (limited to 'src/Filesystem') diff --git a/src/Filesystem/CreateDirectory.php b/src/Filesystem/CreateDirectory.php deleted file mode 100644 index 2621169..0000000 --- a/src/Filesystem/CreateDirectory.php +++ /dev/null @@ -1,49 +0,0 @@ - - */ -class CreateDirectory implements TaskInterface -{ - /** - * Directory to create - * - * @var string - */ - protected $directory; - - /** - * Check if the directory already exists - * - * @param string $filename - * @author Phil Burton - */ - public function __construct(string $directory) - { - $this->directory = $directory; - - if (!is_writable(dirname($directory))) { - throw new \Exception('Cannot create directory at: ' . $directory); - } - - if (file_exists($directory)) { - throw new \Exception('Directory already exists at: ' . $directory); - } - } - - /** - * Create the new directory - * - * @author Phil Burton - */ - public function execute() - { - mkdir($this->directory); - } -} 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 @@ - - */ -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 - */ - 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 - */ - public function execute() - { - touch($this->filename); - - $contents = $this->contents; - if ($contents) { - file_put_contents($this->filename, $contents); - } - } -} -- cgit v1.2.3