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

DeleteLastMigrationAction::execute()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 3
nc 3
nop 0
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