Apache Zeta Components Manual :: File Source for mail_address.php

Source for file mail_address.php

Documentation is available at mail_address.php

  1. <?php
  2. /**
  3.  *
  4.  * Licensed to the Apache Software Foundation (ASF) under one
  5.  * or more contributor license agreements.  See the NOTICE file
  6.  * distributed with this work for additional information
  7.  * regarding copyright ownership.  The ASF licenses this file
  8.  * to you under the Apache License, Version 2.0 (the
  9.  * "License"); you may not use this file except in compliance
  10.  * with the License.  You may obtain a copy of the License at
  11.  * 
  12.  *   http://www.apache.org/licenses/LICENSE-2.0
  13.  * 
  14.  * Unless required by applicable law or agreed to in writing,
  15.  * software distributed under the License is distributed on an
  16.  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  17.  * KIND, either express or implied.  See the License for the
  18.  * specific language governing permissions and limitations
  19.  * under the License.
  20.  *
  21.  * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
  22.  * @version //autogentag//
  23.  * @filesource
  24.  * @package Mail
  25.  */
  26.  
  27. /**
  28.  * A container to store a mail address in RFC822 format.
  29.  *
  30.  * The class ezcMailTools contains methods for transformation between several
  31.  * formats.
  32.  *
  33.  * @package Mail
  34.  * @version //autogentag//
  35.  * @mainclass
  36.  */
  37. class ezcMailAddress extends ezcBaseStruct
  38. {
  39.     /**
  40.      * The name of the recipient (optional).
  41.      *
  42.      * @var string 
  43.      */
  44.     public $name;
  45.  
  46.     /**
  47.      * The email address of the recipient.
  48.      *
  49.      * @var string 
  50.      */
  51.     public $email;
  52.  
  53.     /**
  54.      * The character set used in the $name property.
  55.      *
  56.      * The characterset defaults to us-ascii.
  57.      */
  58.     public $charset;
  59.  
  60.     /**
  61.      * Constructs a new ezcMailAddress with the mail address $email and the optional name $name.
  62.      *
  63.      * @param string $email 
  64.      * @param string $name 
  65.      * @param string $charset 
  66.      */
  67.     public function __construct$email$name ''$charset 'us-ascii' )
  68.     {
  69.         $this->name = $name;
  70.         $this->email = $email;
  71.         $this->charset = $charset;
  72.     }
  73.  
  74.     /**
  75.      * Returns a new instance of this class with the data specified by $array.
  76.      *
  77.      * $array contains all the data members of this class in the form:
  78.      * array('member_name'=>value).
  79.      *
  80.      * __set_state makes this class exportable with var_export.
  81.      * var_export() generates code, that calls this method when it
  82.      * is parsed with PHP.
  83.      *
  84.      * @param array(string=>mixed) $array 
  85.      * @return ezcMailAddress 
  86.      */
  87.     static public function __set_statearray $array )
  88.     {
  89.         return new ezcMailAddress$array['email']$array['name');
  90.     }
  91.  
  92.     /**
  93.      * Returns string representation of email address on string cast.
  94.      *
  95.      * Builds a representation in format "Name <email@example.com>", if name
  96.      * is present, else only "<email@example.com>", if name is not present. You
  97.      * can simply do echo with an object of type ezcMailAddress or (since PHP
  98.      * 5.2) explicitly cast it to string using (string) $object.
  99.      *
  100.      * @return string String representation of the email address.
  101.      */
  102.     public function __toString()
  103.     {
  104.         return !empty$this->name "{$this->name} "" "<{$this->email}>";
  105.     }
  106. }
  107. ?>
Documentation generated by phpDocumentor 1.4.3