Issues (44)

Console/Commands/EnvDatabaseConfigSeedCommand.php (9 issues)

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
The trait Ikechukwukalu\Dynamicdat...ig\Trait\DatabaseConfig requires some properties which are not provided by Ikechukwukalu\Dynamicdat...tabaseConfigSeedCommand: $database, $configuration
Loading history...
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
Bug Best Practice introduced by
The property components does not exist on Ikechukwukalu\Dynamicdat...tabaseConfigSeedCommand. Did you maybe forget to declare it?
Loading history...
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 ignore-type  annotation

42
        $newConfig = $this->setNewEnvConfig($database, /** @scrutinizer ignore-type */ $postFix);
Loading history...
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 ignore-type  annotation

42
        $newConfig = $this->setNewEnvConfig(/** @scrutinizer ignore-type */ $database, $postFix);
Loading history...
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 ignore-type  annotation

43
        $this->addNewConfig(/** @scrutinizer ignore-type */ $database, $name, $newConfig);
Loading history...
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 ignore-type  annotation

43
        $this->addNewConfig($database, /** @scrutinizer ignore-type */ $name, $newConfig);
Loading history...
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 ignore-type  annotation

44
        $this->createDatabase(/** @scrutinizer ignore-type */ $database, $newConfig['database']);
Loading history...
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 ignore-type  annotation

45
        $this->execSeederCommands(/** @scrutinizer ignore-type */ $name);
Loading history...
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 ignore-unused  annotation

48
    private function execSeederCommands(/** @scrutinizer ignore-unused */ string $name)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
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