Completed
Push — dev ( 6bece5...cad8d6 )
by Zach
02:11
created

DirectoryCreator::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 5
rs 9.4285
1
<?php
2
3
namespace Yarak\DB;
4
5
use Yarak\Helpers\Creator;
6
7
class DirectoryCreator extends Creator
8
{
9
    /**
10
     * Create all the directories and files necessary for Yarak DB functions.
11
     */
12
    public function create()
13
    {
14
        $this->createAllDirectories();
15
16
        $this->createFactoriesFile();
17
18
        $this->createSeederFile();
19
    }
20
21
    /**
22
     * Create all needed directories.
23
     */
24
    protected function createAllDirectories()
25
    {
26
        $this->makeDirectoryStructure(
27
            $this->config->getAllDatabaseDirectories()
28
        );
29
30
        $this->output->writeInfo('Created migrations directory.');
31
32
        $this->output->writeInfo('Created seeds directory.');
33
34
        $this->output->writeInfo('Created factories directory.');
35
    }
36
37
    /**
38
     * Create factory file stub.
39
     */
40 View Code Duplication
    protected function createFactoriesFile()
41
    {
42
        $stub = file_get_contents(__DIR__.'/Stubs/factory.stub');
43
44
        $this->writeFile(
45
            $this->config->getFactoryDirectory('ModelFactory.php'),
46
            $stub
47
        );
48
49
        $this->output->writeInfo('Created ModelFactory file.');
50
    }
51
52
    /**
53
     * Create seeder file stub.
54
     */
55 View Code Duplication
    protected function createSeederFile()
56
    {
57
        $stub = file_get_contents(__DIR__.'/Stubs/seeder.stub');
58
59
        $this->writeFile(
60
            $this->config->getSeedDirectory('DatabaseSeeder.php'),
61
            $stub
62
        );
63
64
        $this->output->writeInfo('Created DatabaseSeeder file.');
65
    }
66
}
67