Completed
Push — master ( 8e707c...9307a2 )
by Maarten
01:15
created

DeleteMigrationAction   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 20
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A execute() 0 13 3
1
<?php
2
3
namespace Mtolhuys\LaravelSchematics\Actions;
4
5
use Illuminate\Support\Str;
6
use Illuminate\Support\Facades\File;
7
use Mtolhuys\LaravelSchematics\Services\RuleParser;
8
9
class DeleteMigrationAction
10
{
11
    /**
12
     * @param $request
13
     * @return string
14
     */
15
    public function execute($request)
16
    {
17
        $table = Str::plural(Str::snake(
18
            substr($request['name'], strrpos($request['name'], '\\' )+1)
19
        ));
20
        $migrations = scandir(base_path('database/migrations/'));
21
22
        foreach ($migrations as $migration) {
23
            if (strpos($migration, $table) !== false) {
24
                File::delete(base_path("database/migrations/$migration"));
25
            }
26
        }
27
    }
28
}
29