1 | <?php |
||||||
2 | |||||||
3 | namespace Ikechukwukalu\Dynamicdatabaseconfig\Console\Commands; |
||||||
4 | |||||||
5 | use Illuminate\Console\Command; |
||||||
6 | use Ikechukwukalu\Dynamicdatabaseconfig\Trait\DatabaseConfig; |
||||||
7 | |||||||
8 | class EnvDatabaseConfigSeedCommand extends Command |
||||||
9 | { |
||||||
10 | use DatabaseConfig; |
||||||
0 ignored issues
–
show
introduced
by
![]() |
|||||||
11 | |||||||
12 | /** |
||||||
13 | * The name and signature of the console command. |
||||||
14 | * |
||||||
15 | * @var string |
||||||
16 | */ |
||||||
17 | protected $signature = 'env:seed |
||||||
18 | {database : The type of database} |
||||||
19 | {name : The name of the new database connection} |
||||||
20 | {postfix : The postfix for the database configuration} |
||||||
21 | {--seed : Running seeders} |
||||||
22 | {--seeder= : Running a single seeder class}'; |
||||||
23 | |||||||
24 | /** |
||||||
25 | * The console command description. |
||||||
26 | * |
||||||
27 | * @var string |
||||||
28 | */ |
||||||
29 | protected $description = 'Seeding into databases from env'; |
||||||
30 | |||||||
31 | /** |
||||||
32 | * Execute the console command. |
||||||
33 | */ |
||||||
34 | public function handle(): void |
||||||
35 | { |
||||||
36 | $database = $this->argument('database'); |
||||||
37 | $name = $this->argument('name'); |
||||||
38 | $postFix = $this->argument('postfix'); |
||||||
39 | |||||||
40 | $this->components->info("Running seeder(s) for {$name}"); |
||||||
0 ignored issues
–
show
|
|||||||
41 | |||||||
42 | $newConfig = $this->setNewEnvConfig($database, $postFix); |
||||||
0 ignored issues
–
show
It seems like
$postFix can also be of type array and null ; however, parameter $postFix of Ikechukwukalu\Dynamicdat...mand::setNewEnvConfig() does only seem to accept 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
![]() It seems like
$database can also be of type array and null ; however, parameter $database of Ikechukwukalu\Dynamicdat...mand::setNewEnvConfig() does only seem to accept 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
![]() |
|||||||
43 | $this->addNewConfig($database, $name, $newConfig); |
||||||
0 ignored issues
–
show
It seems like
$database can also be of type array and null ; however, parameter $database of Ikechukwukalu\Dynamicdat...Command::addNewConfig() does only seem to accept 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
![]() It seems like
$name can also be of type array and null ; however, parameter $name of Ikechukwukalu\Dynamicdat...Command::addNewConfig() does only seem to accept 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
![]() |
|||||||
44 | $this->createDatabase($database, $newConfig['database']); |
||||||
0 ignored issues
–
show
It seems like
$database can also be of type array and null ; however, parameter $database of Ikechukwukalu\Dynamicdat...mmand::createDatabase() does only seem to accept 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
![]() |
|||||||
45 | $this->execSeederCommands($name); |
||||||
0 ignored issues
–
show
It seems like
$name can also be of type array and null ; however, parameter $name of Ikechukwukalu\Dynamicdat...d::execSeederCommands() does only seem to accept 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
![]() |
|||||||
46 | } |
||||||
47 | |||||||
48 | private function execSeederCommands(string $name) |
||||||
0 ignored issues
–
show
The parameter
$name is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. ![]() |
|||||||
49 | { |
||||||
50 | |||||||
51 | if ($this->option('seed')) { |
||||||
52 | $this->call('db:seed'); |
||||||
53 | return; |
||||||
54 | } |
||||||
55 | |||||||
56 | if ($seeder = $this->option('seeder')) { |
||||||
57 | $this->call('db:seed', ['--class' => $seeder]); |
||||||
58 | } |
||||||
59 | } |
||||||
60 | } |
||||||
61 |