You are here

class AuthorTag in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/phpdocumentor/reflection-docblock/src/phpDocumentor/Reflection/DocBlock/Tag/AuthorTag.php \phpDocumentor\Reflection\DocBlock\Tag\AuthorTag

Reflection class for an @author tag in a Docblock.

@author Mike van Riel <mike.vanriel@naenius.com> @license http://www.opensource.org/licenses/mit-license.php MIT @link http://phpdoc.org

Hierarchy

  • class \phpDocumentor\Reflection\DocBlock\Tag implements \phpDocumentor\Reflection\DocBlock\Reflector
    • class \phpDocumentor\Reflection\DocBlock\Tag\AuthorTag

Expanded class hierarchy of AuthorTag

File

vendor/phpdocumentor/reflection-docblock/src/phpDocumentor/Reflection/DocBlock/Tag/AuthorTag.php, line 24

Namespace

phpDocumentor\Reflection\DocBlock\Tag
View source
class AuthorTag extends Tag {

  /**
   * PCRE regular expression matching any valid value for the name component.
   */
  const REGEX_AUTHOR_NAME = '[^\\<]*';

  /**
   * PCRE regular expression matching any valid value for the email component.
   */
  const REGEX_AUTHOR_EMAIL = '[^\\>]*';

  /** @var string The name of the author */
  protected $authorName = '';

  /** @var string The email of the author */
  protected $authorEmail = '';
  public function getContent() {
    if (null === $this->content) {
      $this->content = $this->authorName;
      if ('' != $this->authorEmail) {
        $this->content .= "<{$this->authorEmail}>";
      }
    }
    return $this->content;
  }

  /**
   * {@inheritdoc}
   */
  public function setContent($content) {
    parent::setContent($content);
    if (preg_match('/^(' . self::REGEX_AUTHOR_NAME . ')(\\<(' . self::REGEX_AUTHOR_EMAIL . ')\\>)?$/u', $this->description, $matches)) {
      $this->authorName = trim($matches[1]);
      if (isset($matches[3])) {
        $this->authorEmail = trim($matches[3]);
      }
    }
    return $this;
  }

  /**
   * Gets the author's name.
   *
   * @return string The author's name.
   */
  public function getAuthorName() {
    return $this->authorName;
  }

  /**
   * Sets the author's name.
   *
   * @param string $authorName The new author name.
   *     An invalid value will set an empty string.
   *
   * @return $this
   */
  public function setAuthorName($authorName) {
    $this->content = null;
    $this->authorName = preg_match('/^' . self::REGEX_AUTHOR_NAME . '$/u', $authorName) ? $authorName : '';
    return $this;
  }

  /**
   * Gets the author's email.
   *
   * @return string The author's email.
   */
  public function getAuthorEmail() {
    return $this->authorEmail;
  }

  /**
   * Sets the author's email.
   *
   * @param string $authorEmail The new author email.
   *     An invalid value will set an empty string.
   *
   * @return $this
   */
  public function setAuthorEmail($authorEmail) {
    $this->authorEmail = preg_match('/^' . self::REGEX_AUTHOR_EMAIL . '$/u', $authorEmail) ? $authorEmail : '';
    $this->content = null;
    return $this;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AuthorTag::$authorEmail protected property @var string The email of the author
AuthorTag::$authorName protected property @var string The name of the author
AuthorTag::getAuthorEmail public function Gets the author's email.
AuthorTag::getAuthorName public function Gets the author's name.
AuthorTag::getContent public function Gets the content of this tag. Overrides Tag::getContent
AuthorTag::REGEX_AUTHOR_EMAIL constant PCRE regular expression matching any valid value for the email component.
AuthorTag::REGEX_AUTHOR_NAME constant PCRE regular expression matching any valid value for the name component.
AuthorTag::setAuthorEmail public function Sets the author's email.
AuthorTag::setAuthorName public function Sets the author's name.
AuthorTag::setContent public function Sets the content of this tag. Overrides Tag::setContent
Tag::$content protected property When set to NULL, it means it needs to be regenerated.
Tag::$description protected property @var string Description of the content of this tag
Tag::$docblock protected property @var DocBlock The DocBlock which this tag belongs to.
Tag::$location protected property @var Location Location of the tag.
Tag::$parsedDescription protected property When set to NULL, it means it needs to be regenerated.
Tag::$tag protected property @var string Name of the tag
Tag::$tagHandlerMappings private static property handles it as an array value. The class is expected to inherit this class.
Tag::createInstance final public static function Factory method responsible for instantiating the correct sub type.
Tag::export public static function Builds a string representation of this object.
Tag::getDescription public function Gets the description component of this tag.
Tag::getDocBlock public function Gets the docblock this tag belongs to.
Tag::getLocation public function Gets the location of the tag.
Tag::getName public function Gets the name of this tag.
Tag::getParsedDescription public function Gets the parsed text of this description.
Tag::REGEX_TAGNAME constant PCRE regular expression matching a tag name.
Tag::registerTagHandler final public static function Registers a handler for tags.
Tag::setDescription public function Sets the description component of this tag.
Tag::setDocBlock public function Sets the docblock this tag belongs to.
Tag::setLocation public function Sets the location of the tag.
Tag::setName public function Sets the name of this tag.
Tag::__construct public function Parses a tag and populates the member variables.
Tag::__toString public function Returns the tag as a serialized string