[ Index ]

MailPress 544

[ Index ]     [ Classes ]     [ Functions ]     [ Variables ]     [ Constants ]     [ Statistics ]    

title

Body

[close]

/mp-includes/Swiftmailer/classes/Swift/Mime/Headers/ -> DateHeader.php (source)

   1  <?php
   2  
   3  /*
   4   * This file is part of SwiftMailer.
   5   * (c) 2004-2009 Chris Corbyn
   6   *
   7   * For the full copyright and license information, please view the LICENSE
   8   * file that was distributed with this source code.
   9   */
  10  
  11  /**
  12   * A Date MIME Header for Swift Mailer.
  13   *
  14   * @author Chris Corbyn
  15   */
  16  class Swift_Mime_Headers_DateHeader extends Swift_Mime_Headers_AbstractHeader
  17  {
  18      /**
  19       * The UNIX timestamp value of this Header.
  20       *
  21       * @var int
  22       */
  23      private $_timestamp;
  24  
  25      /**
  26       * Creates a new DateHeader with $name and $timestamp.
  27       *
  28       * Example:
  29       * <code>
  30       * <?php
  31       * $header = new Swift_Mime_Headers_DateHeader('Date', time());
  32       * ?>
  33       * </code>
  34       *
  35       * @param string             $name    of Header
  36       * @param Swift_Mime_Grammar $grammar
  37       */
  38      public function __construct($name, Swift_Mime_Grammar $grammar)
  39      {
  40          $this->setFieldName($name);
  41          parent::__construct($grammar);
  42      }
  43  
  44      /**
  45       * Get the type of Header that this instance represents.
  46       *
  47       * @see TYPE_TEXT, TYPE_PARAMETERIZED, TYPE_MAILBOX
  48       * @see TYPE_DATE, TYPE_ID, TYPE_PATH
  49       *
  50       * @return int
  51       */
  52      public function getFieldType()
  53      {
  54          return self::TYPE_DATE;
  55      }
  56  
  57      /**
  58       * Set the model for the field body.
  59       *
  60       * This method takes a UNIX timestamp.
  61       *
  62       * @param int $model
  63       */
  64      public function setFieldBodyModel($model)
  65      {
  66          $this->setTimestamp($model);
  67      }
  68  
  69      /**
  70       * Get the model for the field body.
  71       *
  72       * This method returns a UNIX timestamp.
  73       *
  74       * @return mixed
  75       */
  76      public function getFieldBodyModel()
  77      {
  78          return $this->getTimestamp();
  79      }
  80  
  81      /**
  82       * Get the UNIX timestamp of the Date in this Header.
  83       *
  84       * @return int
  85       */
  86      public function getTimestamp()
  87      {
  88          return $this->_timestamp;
  89      }
  90  
  91      /**
  92       * Set the UNIX timestamp of the Date in this Header.
  93       *
  94       * @param int $timestamp
  95       */
  96      public function setTimestamp($timestamp)
  97      {
  98          if (!is_null($timestamp)) {
  99              $timestamp = (int) $timestamp;
 100          }
 101          $this->clearCachedValueIf($this->_timestamp != $timestamp);
 102          $this->_timestamp = $timestamp;
 103      }
 104  
 105      /**
 106       * Get the string value of the body in this Header.
 107       *
 108       * This is not necessarily RFC 2822 compliant since folding white space will
 109       * not be added at this stage (see {@link toString()} for that).
 110       *
 111       * @see toString()
 112       *
 113       * @return string
 114       */
 115      public function getFieldBody()
 116      {
 117          if (!$this->getCachedValue()) {
 118              if (isset($this->_timestamp)) {
 119                  $this->setCachedValue(date('r', $this->_timestamp));
 120              }
 121          }
 122  
 123          return $this->getCachedValue();
 124      }
 125  }


Generated: Thu Apr 28 18:38:52 2016 Cross-referenced by PHPXref 0.7.1