From 7d2128f364c0e81a15653db2508d3e09b262eca1 Mon Sep 17 00:00:00 2001 From: Fbenas Date: Sat, 2 Sep 2017 20:30:30 +0100 Subject: Refactor site:create command to allow creation of extra tasks easier --- src/Filesystem/CreateDirectory.php | 13 ++++--------- src/Filesystem/CreateFile.php | 17 +++++++++++------ 2 files changed, 15 insertions(+), 15 deletions(-) (limited to 'src/Filesystem') diff --git a/src/Filesystem/CreateDirectory.php b/src/Filesystem/CreateDirectory.php index 64c5fba..2621169 100644 --- a/src/Filesystem/CreateDirectory.php +++ b/src/Filesystem/CreateDirectory.php @@ -2,20 +2,15 @@ namespace App\Filesystem; +use App\Task\TaskInterface; + /** * Class to create a new directory * * @author Phil Burton */ -class CreateDirectory +class CreateDirectory implements TaskInterface { - /** - * Thing we're creating - * - * @author Phil Burton - */ - protected $thing = "directory"; - /** * Directory to create * @@ -34,7 +29,7 @@ class CreateDirectory $this->directory = $directory; if (!is_writable(dirname($directory))) { - throw new \Exception('Cannot create ' . $this->thing . ' at: ' . $directory); + throw new \Exception('Cannot create directory at: ' . $directory); } if (file_exists($directory)) { diff --git a/src/Filesystem/CreateFile.php b/src/Filesystem/CreateFile.php index 93c66a6..ce9537f 100644 --- a/src/Filesystem/CreateFile.php +++ b/src/Filesystem/CreateFile.php @@ -2,22 +2,27 @@ namespace App\Filesystem; +use App\Task\TaskInterface; + /** * Class to create a new file * * @author Phil Burton */ -class CreateFile +class CreateFile implements TaskInterface { /** - * Thing we're creating + * Name of file to create * - * @author Phil Burton + * @var string */ - protected $thing = "file"; - protected $filename; + /** + * File contents to write + * + * @var string + */ protected $contents; /** @@ -35,7 +40,7 @@ class CreateFile } if (!is_writable(dirname($filename))) { - throw new \Exception('Cannot create ' . $this->thing . ' at: ' . $filename); + throw new \Exception('Cannot create file at: ' . $filename); } if (file_exists($filename)) { -- cgit v1.2.3