JFIFxxC      C  " }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3RbrconstructConnectionString($params), PGSQL_CONNECT_FORCE_NEW); } catch (ErrorException $e) { throw new Exception($e->getMessage(), '08006', 0, $e); } finally { restore_error_handler(); } if ($connection === false) { throw new Exception('Unable to connect to Postgres server.'); } $driverConnection = new Connection($connection); if (isset($params['application_name'])) { $driverConnection->exec('SET application_name = ' . $driverConnection->quote($params['application_name'])); } return $driverConnection; } /** * Constructs the Postgres connection string * * @param array $params */ private function constructConnectionString( #[SensitiveParameter] array $params ): string { $components = array_filter( [ 'host' => $params['host'] ?? null, 'port' => $params['port'] ?? null, 'dbname' => $params['dbname'] ?? 'postgres', 'user' => $params['user'] ?? null, 'password' => $params['password'] ?? null, 'sslmode' => $params['sslmode'] ?? null, ], static fn ($value) => $value !== '' && $value !== null, ); return implode(' ', array_map( static fn ($value, string $key) => sprintf("%s='%s'", $key, addslashes($value)), array_values($components), array_keys($components), )); } }