DeleteLastMigrationAction::execute()   A
last analyzed

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
     * @return string
14
     */
15
    public function execute()
16
    {
17
        $migrations = scandir($this->path);
18
19
        foreach ($migrations as $index => $migration) {
20
            if ($index === count($migrations) - 1) {
21
                File::delete("$this->path/$migration");
22
            }
23
        }
24
    }
25
}
26