Issues (44)

src/Middleware/EnvDatabaseConfig.php (2 issues)

1
<?php
2
3
namespace Ikechukwukalu\Dynamicdatabaseconfig\Middleware;
4
5
use Closure;
6
use Illuminate\Http\Request;
7
use Ikechukwukalu\Dynamicdatabaseconfig\Trait\DatabaseConfig;
8
9
class EnvDatabaseConfig
10
{
11
    use DatabaseConfig;
0 ignored issues
show
The trait Ikechukwukalu\Dynamicdat...ig\Trait\DatabaseConfig requires some properties which are not provided by Ikechukwukalu\Dynamicdat...eware\EnvDatabaseConfig: $database, $configuration, $name
Loading history...
12
13
    public function handle(Request $request, Closure $next, string $database, string $name, null|string $postFix = null)
14
    {
15
        $request->merge([config('dynamicdatabaseconfig.connection_name', '_db_connection') => $name]);
16
17
        if (!$postFix) {
18
            $postFix = session(config('dynamicdatabaseconfig.session_postfix'));
19
        }
20
21
        $newConfig = $this->setNewEnvConfig($database, $postFix);
0 ignored issues
show
It seems like $postFix can also be of type Illuminate\Session\SessionManager and Illuminate\Session\Store; however, parameter $postFix of Ikechukwukalu\Dynamicdat...nfig::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

21
        $newConfig = $this->setNewEnvConfig($database, /** @scrutinizer ignore-type */ $postFix);
Loading history...
22
        $this->addNewConfig($database, $name, $newConfig);
23
        $this->createDatabase($database, $newConfig['database']);
24
25
        return $next($request);
26
    }
27
28
}
29