Completed
Push — master ( cb1113...b09b3a )
by Maarten
16s queued 11s
created

DeleteLastMigrationAction   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A execute() 0 10 3
1
<?php
2
3
namespace Mtolhuys\LaravelSchematics\Actions\Migration;
4
5
use Illuminate\Support\Facades\File;
6
use Mtolhuys\LaravelSchematics\Actions\Migration\Traits\DeletesMigrations;
7
8
class DeleteLastMigrationAction
9
{
10
    use DeletesMigrations;
11
12
    /**
13
     * @param $request
14
     * @return string
15
     */
16
    public function execute()
17
    {
18
        $migrations = scandir($this->path);
19
20
        foreach ($migrations as $index => $migration) {
21
            if ($index === count($migrations) - 1) {
22
                File::delete("$this->path/$migration");
23
            }
24
        }
25
    }
26
}
27