[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/lib/horde/framework/Horde/Imap/Client/Interaction/ -> Command.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 (LGPL). If you
   6   * did not receive this file, see http://www.horde.org/licenses/lgpl21.
   7   *
   8   * @category  Horde
   9   * @copyright 2012-2014 Horde LLC
  10   * @license   http://www.horde.org/licenses/lgpl21 LGPL 2.1
  11   * @package   Imap_Client
  12   */
  13  
  14  /**
  15   * An object representing an IMAP command (RFC 3501 [2.2.1]).
  16   *
  17   * @author    Michael Slusarz <slusarz@horde.org>
  18   * @category  Horde
  19   * @copyright 2012-2014 Horde LLC
  20   * @license   http://www.horde.org/licenses/lgpl21 LGPL 2.1
  21   * @package   Imap_Client
  22   * @since     2.10.0
  23   *
  24   * @property-read boolean $continuation  True if the command requires a server
  25   *                                       continuation response.
  26   */
  27  class Horde_Imap_Client_Interaction_Command
  28  extends Horde_Imap_Client_Data_Format_List
  29  {
  30      /**
  31       * Debug string to use instead of command text.
  32       *
  33       * @var string
  34       */
  35      public $debug = null;
  36  
  37      /**
  38       * Use LITERAL+ if available
  39       *
  40       * @var boolean
  41       */
  42      public $literalplus = true;
  43  
  44      /**
  45       * Are literal8's available?
  46       *
  47       * @var boolean
  48       */
  49      public $literal8 = false;
  50  
  51      /**
  52       * Server response.
  53       *
  54       * @var Horde_Imap_Client_Interaction_Server
  55       */
  56      public $response;
  57  
  58      /**
  59       * The command tag.
  60       *
  61       * @var string
  62       */
  63      public $tag;
  64  
  65      /**
  66       * Command timer.
  67       *
  68       * @var Horde_Support_Timer
  69       */
  70      protected $_timer;
  71  
  72      /**
  73       * Constructor.
  74       *
  75       * @param string $cmd  The IMAP command.
  76       * @param string $tag  The tag to use. If not set, will be automatically
  77       *                     generated.
  78       */
  79      public function __construct($cmd, $tag = null)
  80      {
  81          $this->tag = is_null($tag)
  82              ? substr(new Horde_Support_Randomid(), 0, 10)
  83              : strval($tag);
  84  
  85          parent::__construct($this->tag);
  86  
  87          $this->add($cmd);
  88      }
  89  
  90      /**
  91       */
  92      public function __get($name)
  93      {
  94          switch ($name) {
  95          case 'continuation':
  96              foreach ($this as $val) {
  97                  if (($val instanceof Horde_Imap_Client_Interaction_Command_Continuation) ||
  98                      (($val instanceof Horde_Imap_Client_Data_Format_String) &&
  99                       $val->literal())) {
 100  
 101                      return true;
 102                  }
 103              }
 104              return false;
 105          }
 106      }
 107  
 108      /**
 109       * Get the command.
 110       *
 111       * @return string  The command.
 112       */
 113      public function getCommand()
 114      {
 115          return $this->_data[1];
 116      }
 117  
 118      /**
 119       * Start the command timer.
 120       */
 121      public function startTimer()
 122      {
 123          $this->_timer = new Horde_Support_Timer();
 124          $this->_timer->push();
 125      }
 126  
 127      /**
 128       * Return the timer data.
 129       *
 130       * @return mixed  Null if timer wasn't started, or a float containing
 131       *                elapsed command time.
 132       */
 133      public function getTimer()
 134      {
 135          return $this->_timer
 136              ? round($this->_timer->pop(), 4)
 137              : null;
 138      }
 139  
 140  }


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