Completed
Pull Request — master (#41)
by
unknown
01:55
created

Mysql::dropAllTables()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 8
nc 1
nop 0
1
<?php
2
3
namespace Spatie\MigrateFresh\TableDroppers;
4
5
use stdClass;
6
use Illuminate\Support\Facades\DB;
7
use Illuminate\Support\Facades\Schema;
8
9
class Mysql implements TableDropper
10
{
11
    public function dropAllTables()
12
    {
13
        Schema::disableForeignKeyConstraints();
14
15
        collect(DB::select("SHOW FULL TABLES WHERE Table_Type = 'BASE TABLE'"))
16
            ->map(function (stdClass $tableProperties) {
17
                return get_object_vars($tableProperties)[key($tableProperties)];
18
            })
19
            ->each(function (string $tableName) {
20
                $tableName = str_after($tableName, Schema::getConnection()->getTablePrefix())
21
                Schema::drop($tableName);
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_STRING
Loading history...
22
            });
23
24
        Schema::enableForeignKeyConstraints();
25
    }
26
}
27