mirror of
https://github.com/codeigniter4/CodeIgniter4.git
synced 2025-02-20 11:44:28 +08:00
refactor: move if conditions to isValidDSN()
This commit is contained in:
parent
5ee0df20c4
commit
99346b48aa
@ -104,6 +104,10 @@ class Connection extends BaseConnection
|
||||
*/
|
||||
private function isValidDSN(): bool
|
||||
{
|
||||
if ($this->DSN === null || $this->DSN === '') {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($this->validDSNs as $regexp) {
|
||||
if (preg_match($regexp, $this->DSN)) {
|
||||
return true;
|
||||
@ -120,7 +124,7 @@ class Connection extends BaseConnection
|
||||
*/
|
||||
public function connect(bool $persistent = false)
|
||||
{
|
||||
if ($this->DSN === null || $this->DSN === '' || ! $this->isValidDSN()) {
|
||||
if (! $this->isValidDSN()) {
|
||||
$this->buildDSN();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user