CitiesTableSeeder   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 15
dl 0
loc 20
c 0
b 0
f 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 18 1
1
<?php
2
3
namespace Turahe\Master\Seeds;
4
5
use Illuminate\Database\Seeder;
6
use Turahe\Master\Models\City;
7
8
class CitiesTableSeeder extends Seeder
9
{
10
    public function run()
11
    {
12
        $Csv = new CsvtoArray();
13
        $file = __DIR__.'/../../resources/csv/cities.csv';
14
        $header = ['id', 'province_id', 'name', 'lat', 'long'];
15
        $data = $Csv->csv_to_array($file, $header);
16
        $cities = array_map(function ($arr) {
17
            return [
18
                'state_id' => $arr['province_id'],
19
                'name' => $arr['name'],
20
                'latitude' => $arr['lat'],
21
                'longitude' => $arr['long'],
22
                'created_at' => now()->toDateTimeString(),
23
                'updated_at' => now()->toDateTimeString(),
24
            ];
25
        }, $data);
0 ignored issues
show
Bug introduced by
It seems like $data can also be of type false; however, parameter $arr1 of array_map() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

25
        }, /** @scrutinizer ignore-type */ $data);
Loading history...
26
27
        City::insert($cities);
28
    }
29
}
30