Tables::getBaseMigrationsPath()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace PragmaRX\Tracker\Vendor\Laravel\Artisan;
4
5
class Tables extends Base
6
{
7
    /**
8
     * Command name.
9
     *
10
     * @var string
11
     */
12
    protected $name = 'tracker:tables';
13
14
    /**
15
     * Command description.
16
     *
17
     * @var string
18
     */
19
    protected $description = 'Create the migrations for Tracker database tables and columns';
20
21
    /**
22
     * Execute the command.
23
     *
24
     * @return void
25
     */
26
    public function handle()
27
    {
28
        $this->fire();
29
    }
30
31
    /**
32
     * Execute the command.
33
     *
34
     * @return void
35
     */
36
    public function fire()
37
    {
38
        $files = $this->laravel->make('files');
39
40
        foreach ($files->files($this->getPackageMigrationsPath()) as $file) {
41
            if (!file_exists($destination = $this->makeMigrationPath($file))) {
42
                $files->copy($file, $destination);
43
44
                $this->info("Migration created: $destination");
45
            }
46
        }
47
    }
48
49
    /**
50
     * Get the package migrations folder.
51
     *
52
     * @return string
53
     */
54
    protected function getPackageMigrationsPath()
55
    {
56
        $ds = DIRECTORY_SEPARATOR;
57
58
        return __DIR__."{$ds}..{$ds}..{$ds}..{$ds}migrations";
59
    }
60
61
    /**
62
     * Get the system migrations folder.
63
     *
64
     * @return string
65
     */
66
    protected function getBaseMigrationsPath()
67
    {
68
        $path = 'database'.DIRECTORY_SEPARATOR.'migrations';
69
70
        return base_path($path);
71
    }
72
73
    /**
74
     * Make a full path migration name.
75
     *
76
     * @param $file
77
     *
78
     * @return string
79
     */
80
    private function makeMigrationPath($file)
81
    {
82
        return $this->getBaseMigrationsPath().DIRECTORY_SEPARATOR.basename($file);
83
    }
84
}
85