authorName = $authorName; $this->authorEmail = $authorEmail; } /** * Gets the author's name. * * @return string The author's name. */ public function getAuthorName() : string { return $this->authorName; } /** * Returns the author's email. * * @return string The author's email. */ public function getEmail() : string { return $this->authorEmail; } /** * Returns this tag in string form. */ public function __toString() : string { if ($this->authorEmail) { $authorEmail = '<' . $this->authorEmail . '>'; } else { $authorEmail = ''; } $authorName = (string) $this->authorName; return $authorName . ($authorEmail !== '' ? ($authorName !== '' ? ' ' : '') . $authorEmail : ''); } /** * Attempts to create a new Author object based on †he tag body. */ public static function create(string $body) : ?self { $splitTagContent = preg_match('/^([^\<]*)(?:\<([^\>]*)\>)?$/u', $body, $matches); if (!$splitTagContent) { return null; } $authorName = trim($matches[1]); $email = isset($matches[2]) ? trim($matches[2]) : ''; return new static($authorName, $email); } }