Explorar el Código

ZF-7352: slight cleanup of conditionals in setFrom and setReplyTo

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@18578 44c647ce-9c0f-0410-b52a-842ac1e357ba
matthew hace 16 años
padre
commit
11978fd750
Se han modificado 1 ficheros con 13 adiciones y 12 borrados
  1. 13 12
      library/Zend/Mail.php

+ 13 - 12
library/Zend/Mail.php

@@ -603,18 +603,19 @@ class Zend_Mail extends Zend_Mime_Message
      */
     public function setFrom($email, $name = null)
     {
-        if ($this->_from === null) {
-            $email = $this->_filterEmail($email);
-            $name  = $this->_filterName($name);
-            $this->_from = $email;
-            $this->_storeHeader('From', $this->_formatAddress($email, $name), true);
-        } else {
+        if (null !== $this->_from) {
             /**
              * @see Zend_Mail_Exception
              */
             require_once 'Zend/Mail/Exception.php';
             throw new Zend_Mail_Exception('From Header set twice');
         }
+
+        $email = $this->_filterEmail($email);
+        $name  = $this->_filterName($name);
+        $this->_from = $email;
+        $this->_storeHeader('From', $this->_formatAddress($email, $name), true);
+
         return $this;
     }
 
@@ -628,12 +629,7 @@ class Zend_Mail extends Zend_Mime_Message
      */
     public function setReplyTo($email, $name = null)
     {
-        if($this->_replyTo === null) {
-            $email = $this->_filterEmail($email);
-            $name  = $this->_filterName($name);
-            $this->_replyTo = $email;
-            $this->_storeHeader('Reply-To', $this->_formatAddress($email, $name), true);
-        } else {
+        if (null !== $this->_replyTo) {
             /**
              * @see Zend_Mail_Exception
              */
@@ -641,6 +637,11 @@ class Zend_Mail extends Zend_Mime_Message
             throw new Zend_Mail_Exception('Reply-To Header set twice');
         }
 
+        $email = $this->_filterEmail($email);
+        $name  = $this->_filterName($name);
+        $this->_replyTo = $email;
+        $this->_storeHeader('Reply-To', $this->_formatAddress($email, $name), true);
+
         return $this;
     }