You are here

public function Serializer::getDocComment in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/phpdocumentor/reflection-docblock/src/phpDocumentor/Reflection/DocBlock/Serializer.php \phpDocumentor\Reflection\DocBlock\Serializer::getDocComment()

Generate a DocBlock comment.

Parameters

DocBlock The DocBlock to serialize.:

Return value

string The serialized doc block.

File

vendor/phpdocumentor/reflection-docblock/src/phpDocumentor/Reflection/DocBlock/Serializer.php, line 168

Class

Serializer
Serializes a DocBlock instance.

Namespace

phpDocumentor\Reflection\DocBlock

Code

public function getDocComment(DocBlock $docblock) {
  $indent = str_repeat($this->indentString, $this->indent);
  $firstIndent = $this->isFirstLineIndented ? $indent : '';
  $text = $docblock
    ->getText();
  if ($this->lineLength) {

    //3 === strlen(' * ')
    $wrapLength = $this->lineLength - strlen($indent) - 3;
    $text = wordwrap($text, $wrapLength);
  }
  $text = str_replace("\n", "\n{$indent} * ", $text);
  $comment = "{$firstIndent}/**\n{$indent} * {$text}\n{$indent} *\n";

  /** @var Tag $tag */
  foreach ($docblock
    ->getTags() as $tag) {
    $tagText = (string) $tag;
    if ($this->lineLength) {
      $tagText = wordwrap($tagText, $wrapLength);
    }
    $tagText = str_replace("\n", "\n{$indent} * ", $tagText);
    $comment .= "{$indent} * {$tagText}\n";
  }
  $comment .= $indent . ' */';
  return $comment;
}