Merge "Update magic words and special page aliases for Arabic and Egyptian Arabic"
[lhc/web/wiklou.git] / includes / mail / MailAddress.php
index 972d291..ce1df0d 100644 (file)
  * header format when requested.
  */
 class MailAddress {
+
+       /**
+        * @var string
+        */
+       public $name;
+
+       /**
+        * @var string
+        */
+       public $realName;
+
        /**
-        * @param string|User $address String with an email address, or a User object
+        * @var string
+        */
+       public $address;
+
+       /**
+        * @param string $address String with an email address, or a User object
         * @param string $name Human-readable name if a string address is given
         * @param string $realName Human-readable real name if a string address is given
         */
        function __construct( $address, $name = null, $realName = null ) {
                if ( is_object( $address ) && $address instanceof User ) {
+                       // Old calling format, now deprecated
+                       wfDeprecated( __METHOD__ . ' with a User object', '1.24' );
                        $this->address = $address->getEmail();
                        $this->name = $address->getName();
                        $this->realName = $address->getRealName();
@@ -47,6 +65,17 @@ class MailAddress {
                }
        }
 
+       /**
+        * Create a new MailAddress object for the given user
+        *
+        * @since 1.24
+        * @param User $user
+        * @return MailAddress
+        */
+       public static function newFromUser( User $user ) {
+               return new MailAddress( $user->getEmail(), $user->getName(), $user->getRealName() );
+       }
+
        /**
         * Return formatted and quoted address to insert into SMTP headers
         * @return string