Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.
   1  <?php
   2  /**
   3   * Copyright 2012-2017 Horde LLC (http://www.horde.org/)
   4   *
   5   * See the enclosed file LICENSE for license information (LGPL). If you
   6   * did not receive this file, see http://www.horde.org/licenses/lgpl21.
   7   *
   8   * @category  Horde
   9   * @copyright 2012-2017 Horde LLC
  10   * @license   http://www.horde.org/licenses/lgpl21 LGPL 2.1
  11   * @package   Imap_Client
  12   */
  13  
  14  /**
  15   * Object representation of an IMAP data format (RFC 3501 [4]).
  16   *
  17   * @author    Michael Slusarz <slusarz@horde.org>
  18   * @category  Horde
  19   * @copyright 2012-2017 Horde LLC
  20   * @license   http://www.horde.org/licenses/lgpl21 LGPL 2.1
  21   * @package   Imap_Client
  22   */
  23  class Horde_Imap_Client_Data_Format
  24  {
  25      /**
  26       * Data.
  27       *
  28       * @var mixed
  29       */
  30      protected $_data;
  31  
  32      /**
  33       * Constructor.
  34       *
  35       * @param mixed $data  Data.
  36       */
  37      public function __construct($data)
  38      {
  39          $this->_data = is_resource($data)
  40              ? stream_get_contents($data, -1, 0)
  41              : $data;
  42      }
  43  
  44      /**
  45       * Returns the string value of the raw data.
  46       *
  47       * @return string  String value.
  48       */
  49      public function __toString()
  50      {
  51          return strval($this->_data);
  52      }
  53  
  54      /**
  55       * Returns the raw data.
  56       *
  57       * @return mixed  Raw data.
  58       */
  59      public function getData()
  60      {
  61          return $this->_data;
  62      }
  63  
  64      /**
  65       * Returns the data formatted for output to the IMAP server.
  66       *
  67       * @return string  IMAP escaped string.
  68       */
  69      public function escape()
  70      {
  71          return strval($this);
  72      }
  73  
  74      /**
  75       * Verify the data.
  76       *
  77       * @throws Horde_Imap_Client_Data_Format_Exception
  78       */
  79      public function verify()
  80      {
  81      }
  82  
  83  }