@@ -40,7 +40,7 @@ public function __construct(
40
40
41
41
public static function fromEnv (string $ alias , ?array $ env = null )
42
42
{
43
- $ env = is_null ( $ env) ? $ _ENV : $ env ;
43
+ $ env = $ env ?? getenv () ;
44
44
$ alias = strtoupper ($ alias );
45
45
46
46
$ driver = DriverManager::fromEnv ($ alias , $ env );
@@ -53,16 +53,16 @@ public static function fromEnv(string $alias, ?array $env = null)
53
53
$ pwflKey = "DATABASE_ {$ alias }_PSWD_FILE " ;
54
54
$ instKey = "DATABASE_ {$ alias }_INST " ;
55
55
56
- $ host = getenv ( $ hostKey) ?? $ driver ->getDefaultHost ();
57
- $ port = getenv ( $ portKey) ?? $ driver ->getDefaultPort ();
58
- $ user = getenv ( $ userKey) ?? $ driver ->getDefaultUser ();
59
- $ name = getenv ( $ nameKey) ?? $ alias ;
60
- $ encd = getenv ( $ encdKey) ?? null ;
61
- $ inst = getenv ( $ instKey) ?? null ;
56
+ $ host = $ env [ $ hostKey] ?? $ driver ->getDefaultHost ();
57
+ $ port = $ env [ $ portKey] ?? $ driver ->getDefaultPort ();
58
+ $ user = $ env [ $ userKey] ?? $ driver ->getDefaultUser ();
59
+ $ name = $ env [ $ nameKey] ?? $ alias ;
60
+ $ encd = $ env [ $ encdKey] ?? null ;
61
+ $ inst = $ env [ $ instKey] ?? null ;
62
62
63
- $ pswd = getenv ( $ pswdKey) ?? $ driver ->getDefaultPswd ();
64
- if (!empty (getenv ( $ pwflKey)) && file_exists (getenv ( $ pwflKey) )) {
65
- $ pswd = file_get_contents (getenv ( $ pwflKey) );
63
+ $ pswd = $ env [ $ pswdKey] ?? $ driver ->getDefaultPswd ();
64
+ if (!empty ($ env [ $ pwflKey]) && file_exists ($ env [ $ pwflKey] )) {
65
+ $ pswd = file_get_contents ($ env [ $ pwflKey] );
66
66
}
67
67
68
68
return new ConnectParams ($ driver , $ host , $ user , $ pswd , $ name , $ port , $ encd , $ inst );
0 commit comments