original_string: public function wordWrapText($text, $wrapWidth)
      {
          $wrappedText = '';
          foreach (explode(PHP_EOL, $text) as $line) {
              $words = explode(' ', $line);
              $currentLine = array_shift($words);
              while (count($words) > 0) {
                  $word = array_shift($words);
                  if ($this->getTextWidth($currentLine . ' ' . $word) > $wrapWidth) {
                      $wrappedText .= PHP_EOL . $currentLine;
                      $currentLine = $word;
                  } else {
                      $currentLine .= ' ' . $word;
                  }
              }
              $wrappedText .= PHP_EOL . $currentLine;
          }
          return ltrim($wrappedText, PHP_EOL);
      }
code: public function wordWrapText($text, $wrapWidth)
      {
          $wrappedText = '';
          foreach (explode(PHP_EOL, $text) as $line) {
              $words = explode(' ', $line);
              $currentLine = array_shift($words);
              while (count($words) > 0) {
                  $word = array_shift($words);
                  if ($this->getTextWidth($currentLine . ' ' . $word) > $wrapWidth) {
                      $wrappedText .= PHP_EOL . $currentLine;
                      $currentLine = $word;
                  } else {
                      $currentLine .= ' ' . $word;
                  }
              }
              $wrappedText .= PHP_EOL . $currentLine;
          }
          return ltrim($wrappedText, PHP_EOL);
      }
code_tokens: public function wordWrapText ( $ text , $ wrapWidth ) { $ wrappedText = '' ; foreach ( explode ( PHP_EOL , $ text ) as $ line ) { $ words = explode ( ' ' , $ line ) ; $ currentLine = array_shift ( $ words ) ; while ( count ( $ words ) > 0 ) { $ word = array_shift ( $ words ) ; if ( $ this -> getTextWidth ( $ currentLine . ' ' . $ word ) > $ wrapWidth ) { $ wrappedText .= PHP_EOL . $ currentLine ; $ currentLine = $ word ; } else { $ currentLine .= ' ' . $ word ; } } $ wrappedText .= PHP_EOL . $ currentLine ; } return ltrim ( $ wrappedText , PHP_EOL ) ; }
docstring: Word-wrap a text to a certain width, using the current font properties
  
  @param string $text text to wrap (can already contain some newlines)
  @param string $wrapWidth width (in the given units) to wrap the text to
  @return string the same text but with newlines inserted at the specified $wrapWidth
docstring_tokens: Word - wrap a text to a certain width using the current font properties