summaryrefslogtreecommitdiff
path: root/src/Filesystem/CreateDirectory.php
blob: 2af53d7290585c0170072d2e5c099a6321df91eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php

namespace App\Filesystem;

use App\Filesystem\Create;

/**
 * Class to create a new directory
 *
 * @author Phil Burton <phil@d3r.com>
 */
class CreateDirectory extends Create
{
    /**
     * Thing we're creating
     *
     * @author Phil Burton <phil@d3r.com>
     */
    protected $thing = "directory";

    /**
     * Check if the directory already exists
     *
     * @param string $filename
     * @author Phil Burton <phil@d3r.com>
     */
    public function __construct(string $filename)
    {
        parent::__construct($filename);

        if (file_exists($filename)) {
            throw new \Exception('Directory already exists at: ' . $filename);
        }
    }

    /**
     * Create the new directory
     *
     * @author Phil Burton <phil@d3r.com>
     */
    public function excecute()
    {
        echo "execute";
    }
}