conn = $this->connectWithMySQL($config['args']); } catch (PDOException $e) { throw new PDOException("Database error: " . $e->getMessage()); } } private function connectWithMySQL(array $args): object { $dsn = "mysql:host={$args['host']};dbname={$args['database']};charset={$args['charset']}"; $options = [ PDO::ATTR_PERSISTENT => true, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION ]; return new PDO($dsn, $args['user'], $args['password'], $options); } }