Esempio n. 1
0
 /**
  * Parses a comment string into an object
  *
  * @param String $content The text to parse
  * @return \vc\Data\Comment
  */
 public function parse($content)
 {
     $content = trim($content, " */\t\r\n");
     $content = str_replace(array("\r\n", "\n", "\r"), "\n", $content);
     // Clean up the leading white space and astericks on each line
     $content = preg_replace('/^[ \\t\\*]+/m', '', $content);
     // Match any tags and separate them from the text
     if (preg_match_all('/^@(\\w+)/m', $content, $tags, PREG_SET_ORDER | PREG_OFFSET_CAPTURE)) {
         $offset = reset($tags);
         $text = trim(substr($content, 0, $offset[0][1]));
     } else {
         $text = $content;
     }
     $comment = new \vc\Data\Comment($text);
     // Build and add each tag to this comment
     foreach ($tags as $key => $tag) {
         $comment->addTag(self::buildTag($content, $tag, isset($tags[$key + 1]) ? $tags[$key + 1] : NULL));
     }
     return $comment;
 }