Conditions | 3 |
Paths | 3 |
Total Lines | 17 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 3.0416 |
Changes | 0 |
1 | <?php |
||
16 | 2 | public function handle(): int |
|
17 | { |
||
18 | 2 | $sqlScript = file_get_contents(__DIR__.'/../../storage/uk-towns.sql'); |
|
19 | 2 | if (!$sqlScript) { |
|
20 | $this->error('Script not found.'); |
||
21 | |||
22 | return 1; |
||
23 | } |
||
24 | 2 | $sqlScript = Str::replace('geo_towns', config('uk-towns.tables.towns'), $sqlScript); |
|
25 | 2 | $sqlScripts = explode('-- statement', $sqlScript); |
|
26 | 2 | DB::statement('SET FOREIGN_KEY_CHECKS=0;'); |
|
27 | 2 | foreach ($sqlScripts as $sqlScript) { |
|
28 | 2 | DB::statement(trim($sqlScript)); |
|
29 | } |
||
30 | 2 | DB::statement('SET FOREIGN_KEY_CHECKS=1;'); |
|
31 | |||
32 | 2 | return 0; |
|
33 | } |
||
35 |