[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/lib/horde/framework/Horde/Mail/Rfc822/ -> Object.php (source)

   1  <?php
   2  /**
   3   * Copyright 2012-2014 Horde LLC (http://www.horde.org/)
   4   *
   5   * See the enclosed file COPYING for license information (BSD). If you
   6   * did not receive this file, see http://www.horde.org/licenses/bsd.
   7   *
   8   * @category  Horde
   9   * @copyright 2012-2014 Horde LLC
  10   * @license   http://www.horde.org/licenses/bsd New BSD License
  11   * @package   Mail
  12   */
  13  
  14  /**
  15   * Object representation of an RFC 822 element.
  16   *
  17   * @author    Michael Slusarz <slusarz@horde.org>
  18   * @category  Horde
  19   * @copyright 2012-2014 Horde LLC
  20   * @license   http://www.horde.org/licenses/bsd New BSD License
  21   * @package   Mail
  22   */
  23  abstract class Horde_Mail_Rfc822_Object
  24  {
  25      /**
  26       * String representation of object.
  27       *
  28       * @return string  Returns the full e-mail address.
  29       */
  30      public function __toString()
  31      {
  32          return $this->writeAddress();
  33      }
  34  
  35      /**
  36       * Write an address given information in this part.
  37       *
  38       * @param mixed $opts  If boolean true, is equivalent to passing true for
  39       *                     both 'encode' and 'idn'. If an array, these
  40       *                     keys are supported:
  41       *   - encode: (mixed) MIME encode the personal/groupname parts?
  42       *             If boolean true, encodes in 'UTF-8'.
  43       *             If a string, encodes using this charset.
  44       *             DEFAULT: false
  45       *   - idn: (boolean) If true, encodes IDN domain names
  46       *          (Punycode/RFC 3490).
  47       *          Requires the idn or intl PHP module.
  48       *          DEFAULT: false
  49       *
  50       * @return string  The correctly escaped/quoted address.
  51       */
  52      public function writeAddress($opts = array())
  53      {
  54          if ($opts === true) {
  55              $opts = array(
  56                  'encode' => 'UTF-8',
  57                  'idn' => true
  58              );
  59          } elseif (!empty($opts['encode']) && ($opts['encode'] === true)) {
  60              $opts['encode'] = 'UTF-8';
  61          }
  62  
  63          return $this->_writeAddress($opts);
  64      }
  65  
  66      /**
  67       * Class-specific implementation of writeAddress().
  68       *
  69       * @see writeAddress()
  70       *
  71       * @param array $opts  See writeAddress().
  72       *
  73       * @return string  The correctly escaped/quoted address.
  74       */
  75      abstract protected function _writeAddress($opts);
  76  
  77      /**
  78       * Compare this object against other data.
  79       *
  80       * @param mixed $ob  Address data.
  81       *
  82       * @return boolean  True if the data reflects the same canonical address.
  83       */
  84      abstract public function match($ob);
  85  
  86  }


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1