original_string: public function connect()
      {
          if ($this->isConnected) {
              return false;
          }
  
          if (!$this->pdo) {
              $this->beforeConnect && call_user_func($this->beforeConnect, $this);
  
              $dsn = $this->getDsn();
              $attrs = $this->attrs + array(
                  PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
                  PDO::ATTR_STRINGIFY_FETCHES => true,
                  PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC
              );
  
              try {
                  $this->pdo = new PDO($dsn, $this->user, $this->password, $attrs);
              } catch (\PDOException $e) {
                  $this->connectFails && call_user_func($this->connectFails, $this, $e);
                  throw $e;
              }
  
              $this->afterConnect && call_user_func($this->afterConnect, $this, $this->pdo);
          }
  
          $this->isConnected = true;
  
          return true;
      }
code: public function connect()
      {
          if ($this->isConnected) {
              return false;
          }
  
          if (!$this->pdo) {
              $this->beforeConnect && call_user_func($this->beforeConnect, $this);
  
              $dsn = $this->getDsn();
              $attrs = $this->attrs + array(
                  PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
                  PDO::ATTR_STRINGIFY_FETCHES => true,
                  PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC
              );
  
              try {
                  $this->pdo = new PDO($dsn, $this->user, $this->password, $attrs);
              } catch (\PDOException $e) {
                  $this->connectFails && call_user_func($this->connectFails, $this, $e);
                  throw $e;
              }
  
              $this->afterConnect && call_user_func($this->afterConnect, $this, $this->pdo);
          }
  
          $this->isConnected = true;
  
          return true;
      }
code_tokens: public function connect ( ) { if ( $ this -> isConnected ) { return false ; } if ( ! $ this -> pdo ) { $ this -> beforeConnect && call_user_func ( $ this -> beforeConnect , $ this ) ; $ dsn = $ this -> getDsn ( ) ; $ attrs = $ this -> attrs + array ( PDO :: ATTR_ERRMODE => PDO :: ERRMODE_EXCEPTION , PDO :: ATTR_STRINGIFY_FETCHES => true , PDO :: ATTR_DEFAULT_FETCH_MODE => PDO :: FETCH_ASSOC ) ; try { $ this -> pdo = new PDO ( $ dsn , $ this -> user , $ this -> password , $ attrs ) ; } catch ( \ PDOException $ e ) { $ this -> connectFails && call_user_func ( $ this -> connectFails , $ this , $ e ) ; throw $ e ; } $ this -> afterConnect && call_user_func ( $ this -> afterConnect , $ this , $ this -> pdo ) ; } $ this -> isConnected = true ; return true ; }
docstring: Connect to the database server
  
  @throws \PDOException When fails to connect to database server
  @return boolean
docstring_tokens: Connect to the database server