summaryrefslogtreecommitdiff
path: root/src/Filesystem/CreateDirectory.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Filesystem/CreateDirectory.php')
-rw-r--r--src/Filesystem/CreateDirectory.php16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/Filesystem/CreateDirectory.php b/src/Filesystem/CreateDirectory.php
index 2af53d7..c74cba4 100644
--- a/src/Filesystem/CreateDirectory.php
+++ b/src/Filesystem/CreateDirectory.php
@@ -2,14 +2,12 @@
namespace App\Filesystem;
-use App\Filesystem\Create;
-
/**
* Class to create a new directory
*
* @author Phil Burton <phil@d3r.com>
*/
-class CreateDirectory extends Create
+class CreateDirectory
{
/**
* Thing we're creating
@@ -18,6 +16,8 @@ class CreateDirectory extends Create
*/
protected $thing = "directory";
+ protected $filename;
+
/**
* Check if the directory already exists
*
@@ -26,7 +26,11 @@ class CreateDirectory extends Create
*/
public function __construct(string $filename)
{
- parent::__construct($filename);
+ $this->filename = $filename;
+
+ if (!is_writable(dirname($filename))) {
+ throw new \Exception('Cannot create ' . $this->thing . ' at: ' . $filename);
+ }
if (file_exists($filename)) {
throw new \Exception('Directory already exists at: ' . $filename);
@@ -38,8 +42,8 @@ class CreateDirectory extends Create
*
* @author Phil Burton <phil@d3r.com>
*/
- public function excecute()
+ public function execute()
{
- echo "execute";
+ mkdir($this->filename);
}
}