* @param string|null $name Human-readable name if a string address is given
* @param string|null $realName Human-readable real name if a string address is given
*/
- function __construct( $address, $name = null, $realName = null ) {
+ public function __construct( $address, $name = null, $realName = null ) {
$this->address = strval( $address );
$this->name = strval( $name );
$this->realName = strval( $realName );
* @return string
*/
function toString() {
+ if ( !$this->address ) {
+ return '';
+ }
+
# PHP's mail() implementation under Windows is somewhat shite, and
# can't handle "Joe Bloggs <joe@bloggs.com>" format email addresses,
# so don't bother generating them
- if ( $this->address ) {
- if ( $this->name != '' && !wfIsWindows() ) {
- global $wgEnotifUseRealName;
- $name = ( $wgEnotifUseRealName && $this->realName !== '' ) ? $this->realName : $this->name;
- $quoted = UserMailer::quotedPrintable( $name );
- // Must only be quoted if string does not use =? encoding (T191931)
- if ( $quoted === $name ) {
- $quoted = '"' . addslashes( $quoted ) . '"';
- }
- return "$quoted <{$this->address}>";
- } else {
- return $this->address;
- }
- } else {
- return "";
+ if ( $this->name === '' || wfIsWindows() ) {
+ return $this->address;
}
+
+ global $wgEnotifUseRealName;
+ $name = ( $wgEnotifUseRealName && $this->realName !== '' ) ? $this->realName : $this->name;
+ $quoted = UserMailer::quotedPrintable( $name );
+ // Must only be quoted if string does not use =? encoding (T191931)
+ if ( $quoted === $name ) {
+ $quoted = '"' . addslashes( $quoted ) . '"';
+ }
+
+ return "$quoted <{$this->address}>";
}
function __toString() {