Changeset View
Changeset View
Standalone View
Standalone View
src/parser/PhutilEmailAddress.php
Context not available. | |||||
$email_address = trim($email_address); | $email_address = trim($email_address); | ||||
$matches = null; | $matches = null; | ||||
if (preg_match('/^(.*)<(.*?)>$/', $email_address, $matches)) { | if (@preg_match('/^(.*)<(.*?)>$/', $email_address, $matches)) { | ||||
$display_name = trim($matches[1], '\'" '); | $display_name = trim($matches[1], '\'" '); | ||||
if (strpos($matches[2], '@') !== false) { | if (@strpos($matches[2], '@') !== false) { | ||||
list($local_part, $domain_name) = explode('@', $matches[2], 2); | list($local_part, $domain_name) = @explode('@', $matches[2], 2); | ||||
} else { | } else { | ||||
$local_part = $matches[2]; | $local_part = $matches[2]; | ||||
$domain_name = null; | $domain_name = null; | ||||
} | } | ||||
} else if (preg_match('/^(.*)@(.*)$/', $email_address, $matches)) { | } else if (@preg_match('/^(.*)@(.*)$/', $email_address, $matches)) { | ||||
$display_name = null; | $display_name = null; | ||||
$local_part = $matches[1]; | $local_part = $matches[1]; | ||||
$domain_name = $matches[2]; | $domain_name = $matches[2]; | ||||
Context not available. | |||||
public function __toString() { | public function __toString() { | ||||
$address = $this->getAddress(); | $address = $this->getAddress(); | ||||
if (strlen($this->displayName)) { | if (@strlen($this->displayName)) { | ||||
$display_name = $this->encodeDisplayName($this->displayName); | $display_name = $this->encodeDisplayName($this->displayName); | ||||
return $display_name.' <'.$address.'>'; | return $display_name.' <'.$address.'>'; | ||||
} else { | } else { | ||||
Context not available. | |||||
} | } | ||||
public function setAddress($address) { | public function setAddress($address) { | ||||
$parts = explode('@', $address, 2); | $parts = @explode('@', $address, 2); | ||||
$this->localPart = $parts[0]; | $this->localPart = $parts[0]; | ||||
if (isset($parts[1])) { | if (isset($parts[1])) { | ||||
Context not available. | |||||
public function getAddress() { | public function getAddress() { | ||||
$address = $this->localPart; | $address = $this->localPart; | ||||
if (strlen($this->domainName)) { | if (@strlen($this->domainName)) { | ||||
$address .= '@'.$this->domainName; | $address .= '@'.$this->domainName; | ||||
} | } | ||||
return $address; | return $address; | ||||
Context not available. |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0