1 | <?php |
||||
2 | |||||
3 | namespace LaraGeoData\Console\Commands; |
||||
4 | |||||
5 | use Illuminate\Console\Command; |
||||
6 | use Illuminate\Filesystem\Filesystem; |
||||
7 | |||||
8 | class LoadDataToDBCommand extends Command |
||||
9 | { |
||||
10 | use HasTablesClassesMap, HasSuffixOption; |
||||
11 | |||||
12 | /** |
||||
13 | * The name and signature of the console command. |
||||
14 | * |
||||
15 | * @var string |
||||
16 | */ |
||||
17 | protected $signature = 'geonames:import:file-to-db |
||||
18 | {type : Migration type. } |
||||
19 | {file? : Csv file path. } |
||||
20 | {--suffix= : Suffix used for specify country if need. } |
||||
21 | {--truncate : Truncate table before import. } |
||||
22 | '; |
||||
23 | |||||
24 | /** |
||||
25 | * The console command description. |
||||
26 | * |
||||
27 | * @var string |
||||
28 | */ |
||||
29 | protected $description = 'Upload data from csv file to DB.'; |
||||
30 | |||||
31 | /** |
||||
32 | * The filesystem instance. |
||||
33 | * |
||||
34 | * @var Filesystem |
||||
35 | */ |
||||
36 | protected Filesystem $files; |
||||
37 | |||||
38 | /** |
||||
39 | * Create a new command instance. |
||||
40 | * |
||||
41 | * @param Filesystem $files |
||||
42 | * |
||||
43 | * @return void |
||||
44 | */ |
||||
45 | 18 | public function __construct(Filesystem $files) |
|||
46 | { |
||||
47 | 18 | parent::__construct(); |
|||
48 | |||||
49 | 18 | $this->files = $files; |
|||
50 | 18 | } |
|||
51 | |||||
52 | 11 | public function handle() |
|||
53 | { |
||||
54 | 11 | $this->makeTableObjectNameByType($this->argument('type'), $this->files) |
|||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||
55 | 10 | ->loadData( |
|||
56 | 10 | $this->argument('file'), |
|||
0 ignored issues
–
show
It seems like
$this->argument('file') can also be of type array ; however, parameter $filePath of LaraGeoData\Database\Tables\GeoTable::loadData() does only seem to accept null|string , 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
![]() |
|||||
57 | 10 | $this->getSuffix(), |
|||
58 | 10 | (bool) $this->option('truncate') |
|||
59 | ); |
||||
60 | |||||
61 | 4 | return 0; |
|||
62 | } |
||||
63 | } |
||||
64 |