Mysql   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A dropAllTables() 0 14 1
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
                Schema::drop($tableName);
21
            });
22
23
        Schema::enableForeignKeyConstraints();
24
    }
25
}
26