Completed
Push — master ( 57ad4c...31fe35 )
by Freek
03:26 queued 01:40
created

Mysql   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 1
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 DB;
6
use Schema;
7
use stdClass;
8
9
class Mysql implements TableDropper
10
{
11
    public function dropAllTables()
12
    {
13
        Schema::disableForeignKeyConstraints();
14
15
        collect(DB::select('SHOW TABLES'))
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