original_string: public function connect(array $params) : bool
      {
          $params = $this->addDefaultValue($params);
          $config = $this->getDns($params);
  
          try {
              $this->pdo = new \PDO($config, $params['username'], $params['password'], $params['options']);
              $this->pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
  
              return true;
          } catch (\PDOException $e) {
              echo 'Unable to connect to database, an error occured:' . $e->getMessage();
          }
  
          return false;
      }
code: public function connect(array $params) : bool
      {
          $params = $this->addDefaultValue($params);
          $config = $this->getDns($params);
  
          try {
              $this->pdo = new \PDO($config, $params['username'], $params['password'], $params['options']);
              $this->pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
  
              return true;
          } catch (\PDOException $e) {
              echo 'Unable to connect to database, an error occured:' . $e->getMessage();
          }
  
          return false;
      }
code_tokens: public function connect ( array $ params ) : bool { $ params = $ this -> addDefaultValue ( $ params ) ; $ config = $ this -> getDns ( $ params ) ; try { $ this -> pdo = new \ PDO ( $ config , $ params [ 'username' ] , $ params [ 'password' ] , $ params [ 'options' ] ) ; $ this -> pdo -> setAttribute ( \ PDO :: ATTR_ERRMODE , \ PDO :: ERRMODE_EXCEPTION ) ; return true ; } catch ( \ PDOException $ e ) { echo 'Unable to connect to database, an error occured:' . $ e -> getMessage ( ) ; } return false ; }
docstring: \brief Open a database connection using PDO.
  \details Provides a simple way to initialize a database connection
  and create a PDO instance.
  @param array $params Parameters for initialize connection.
  Index required:
  - <code>username</code>
  - <code>password</code> (can be an empty string)
  Optional index:
  - <code>dbname</code>
  - <code>adapter</code> <b>Default</b>: <code>mysql</code>
  - <code>host</code> <b>Default</b>: <code>localhost</code>
  - <code>options</code> (<i>Array of options passed when creating PDO object</i>)
  @return bool True when the connection is succefully created.
docstring_tokens: \ brief Open a database connection using PDO . \ details Provides a simple way to initialize a database connection and create a PDO instance .