Horde_Imap_Client_Base::sync PHP Method

sync() public method

Synchronize a mailbox from a sync token.
Since: 2.2.0
public sync ( mixed $mailbox, string $token, array $opts = [] ) : Horde_Imap_Client_Data_Sync
$mailbox mixed A mailbox. Either a Horde_Imap_Client_Mailbox object or a string (UTF-8).
$token string A sync token generated by getSyncToken().
$opts array Additional options: - criteria: (integer) Mask of Horde_Imap_Client::SYNC_* criteria to return. Defaults to SYNC_ALL. - ids: (Horde_Imap_Client_Ids) A cached list of UIDs. Unless QRESYNC is available on the server, failure to specify this option means SYNC_VANISHEDUIDS information cannot be returned.
return Horde_Imap_Client_Data_Sync A sync object.
    public function sync($mailbox, $token, array $opts = array())
    {
        if (($token = base64_decode($token, true)) === false) {
            throw new Horde_Imap_Client_Exception_Sync('Bad token.', Horde_Imap_Client_Exception_Sync::BAD_TOKEN);
        }
        $sync = array();
        foreach (explode(',', $token) as $val) {
            $sync[substr($val, 0, 1)] = substr($val, 1);
        }
        return new Horde_Imap_Client_Data_Sync($this, $mailbox, $sync, $this->_syncStatus($mailbox), isset($opts['criteria']) ? $opts['criteria'] : Horde_Imap_Client::SYNC_ALL, isset($opts['ids']) ? $opts['ids'] : null);
    }