refactor: move if conditions to isValidDSN()

This commit is contained in:
kenjis 2024-06-22 17:46:59 +09:00
parent 5ee0df20c4
commit 99346b48aa
No known key found for this signature in database
GPG Key ID: BD254878922AF198

View File

@ -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();
}