Horde_Pack::unpack PHP Method

unpack() public method

Unpack a string.
public unpack ( string $data ) : mixed
$data string The packed string.
return mixed The unpacked data.
    public function unpack($data)
    {
        if (!$data) {
            return $data;
        }
        if (is_string($data)) {
            $mask = unpack('C*', $data[0]);
            $mask = reset($mask);
            $data = substr($data, 1);
            if ($mask & self::COMPRESS_MASK) {
                $data = self::$_compress->decompress($data);
                $mask ^= self::COMPRESS_MASK;
            }
            if (isset(self::$_drivers[$mask])) {
                try {
                    return self::$_drivers[$mask]->unpack($data);
                } catch (Horde_Pack_Exception $e) {
                    throw $e;
                } catch (Exception $e) {
                    /* Unknown exceptions are handled with the throw below. */
                }
            }
        }
        throw new Horde_Pack_Exception('Could not unpack data');
    }

Usage Example

Example #1
0
 /**
  * Loads basic mailbox information.
  *
  * @param string $mailbox    The mailbox to load.
  * @param integer $uidvalid  The IMAP uidvalidity value of the mailbox.
  */
 protected function _loadMailbox($mailbox, $uidvalid = null)
 {
     if (!isset($this->_mbox[$mailbox]) && ($ob = $this->_hash->get($this->_getCid($mailbox)))) {
         try {
             $this->_mbox[$mailbox] = $this->_pack->unpack($ob);
         } catch (Horde_Pack_Exception $e) {
         }
     }
     if (isset($this->_mbox[$mailbox])) {
         if (is_null($uidvalid) || $uidvalid == $this->_mbox[$mailbox]['d']['uidvalid']) {
             return;
         }
         $this->deleteMailbox($mailbox);
     }
     $this->_mbox[$mailbox] = array('d' => array('uidvalid' => $uidvalid), 'u' => new Horde_Imap_Client_Ids());
 }
All Usage Examples Of Horde_Pack::unpack