* @license PHP License * @package Wombat * @subpackage MailMime */ WBClass::load('WBMail_Mime_Part'); /** * Wombat Mail Mime Part Address * * Mime Mails part address * * @version 0.1.0 * @package Wombat * @subpackage MailMime */ class WBMail_Mime_Part_Address extends WBMail_Mime_Part { /** * e-mail address * @var string */ protected $emailAddress; /** * firstname * @var string */ protected $forename; /** * family name * @var surname */ protected $surname; /** * Receive e-mail address for email * * Format e-mail address suitable for header fields like From, To or Cc * * @return string */ public function get() { if (empty($this->emailAddress)) { return ''; } if (empty($this->forename)) { if (empty($this->surname)) { return $this->emailAddress; } $name = $this->surname; } else { $name = $this->forename . ' ' . $this->surname; } return sprintf('%s <%s>', $name, $this->emailAddress); } /** * Get e-mail address * * Return the vanilla e-mail address * * @see Get() * @return string */ public function getEmailAddress() { return $this->emailAddress; } /** * Set plain e-mail address * * @param string $email */ public function setEmailAddress($email) { $this->emailAddress = $email; } /** * Set firstname * * @param $forename */ public function setForename($forename) { $this->forename = $forename; } /** * Fetch forename * * @return string */ public function getForename() { return $this->forename; } /** * Set lastname * * @param $surname */ public function setSurname($surname) { $this->surname = $surname; } /** * Fetch surname * * @return string */ public function getSurname() { return $this->surname; } }