Horde_Imap_Client_Interaction_Server::__construct PHP Method

__construct() public method

Constructor.
public __construct ( Horde_Imap_Client_Tokenize $token )
$token Horde_Imap_Client_Tokenize Tokenized data returned from the server.
    public function __construct(Horde_Imap_Client_Tokenize $token)
    {
        $this->token = $token;
        /* Check for response status. */
        $status = $token->current();
        $valid = array('BAD', 'BYE', 'NO', 'OK', 'PREAUTH');
        if (in_array($status, $valid)) {
            $this->status = constant(__CLASS__ . '::' . $status);
            $resp_text = $token->next();
            /* Check for response code. Only occurs if there is a response
             * status. */
            if (is_string($resp_text) && $resp_text[0] === '[') {
                $resp = new stdClass();
                $resp->data = array();
                if ($resp_text[strlen($resp_text) - 1] === ']') {
                    $resp->code = substr($resp_text, 1, -1);
                } else {
                    $resp->code = substr($resp_text, 1);
                    while (($elt = $token->next()) !== false) {
                        if (is_string($elt) && $elt[strlen($elt) - 1] === ']') {
                            $resp->data[] = substr($elt, 0, -1);
                            break;
                        }
                        $resp->data[] = is_string($elt) ? $elt : $token->flushIterator();
                    }
                }
                $token->next();
                $this->responseCode = $resp;
            }
        }
    }

Usage Example

Esempio n. 1
0
 /**
  * @param string $tag  Response tag.
  */
 public function __construct(Horde_Imap_Client_Tokenize $token, $tag)
 {
     $this->tag = $tag;
     parent::__construct($token);
     if (is_null($this->status)) {
         throw new Horde_Imap_Client_Exception(Horde_Imap_Client_Translation::t("Bad tagged response."));
     }
 }
Horde_Imap_Client_Interaction_Server