original_string: public function connect(): DatabaseConnection
      {
          if (null !== $this->pdo) {
              return $this;
          }
  
          try {
              $pdoCreator = $this->getPdoCreator();
              $this->pdo  = $pdoCreator($this->configuration);
              $this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
              $this->pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
              if ($this->configuration->hasInitialQuery()) {
                  $this->pdo->query($this->configuration->getInitialQuery());
              }
          } catch (PDOException $pdoe) {
              throw new DatabaseException($pdoe->getMessage(), $pdoe);
          }
  
          return $this;
      }
code: public function connect(): DatabaseConnection
      {
          if (null !== $this->pdo) {
              return $this;
          }
  
          try {
              $pdoCreator = $this->getPdoCreator();
              $this->pdo  = $pdoCreator($this->configuration);
              $this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
              $this->pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
              if ($this->configuration->hasInitialQuery()) {
                  $this->pdo->query($this->configuration->getInitialQuery());
              }
          } catch (PDOException $pdoe) {
              throw new DatabaseException($pdoe->getMessage(), $pdoe);
          }
  
          return $this;
      }
code_tokens: public function connect ( ) : DatabaseConnection { if ( null !== $ this -> pdo ) { return $ this ; } try { $ pdoCreator = $ this -> getPdoCreator ( ) ; $ this -> pdo = $ pdoCreator ( $ this -> configuration ) ; $ this -> pdo -> setAttribute ( PDO :: ATTR_ERRMODE , PDO :: ERRMODE_EXCEPTION ) ; $ this -> pdo -> setAttribute ( PDO :: ATTR_DEFAULT_FETCH_MODE , PDO :: FETCH_ASSOC ) ; if ( $ this -> configuration -> hasInitialQuery ( ) ) { $ this -> pdo -> query ( $ this -> configuration -> getInitialQuery ( ) ) ; } } catch ( PDOException $ pdoe ) { throw new DatabaseException ( $ pdoe -> getMessage ( ) , $ pdoe ) ; } return $ this ; }
docstring: establishes the connection
  
  @return  \stubbles\db\pdo\PdoDatabaseConnection
  @throws  \stubbles\db\DatabaseException
docstring_tokens: establishes the connection