protected function onCommand($tag, $type, $line, $lines, $blob)
{
$ok = $type === 'OK';
$no = $type === 'NO';
if ($type === 'BAD') {
$this->log("Server said: " . $line);
}
$raw = ['lines' => $lines, 'blob' => $blob];
switch ($tag) {
case self::TAG_LOGIN:
if ($ok) {
$this->state = self::STATE_AUTHORIZED;
$this->onResponse->executeOne($this, $line);
} elseif ($no) {
$this->log("Failed to login: " . $line);
$this->finish();
}
break;
case self::TAG_LIST:
$this->onResponse->executeOne($this, $ok, $this->decodeList($lines));
break;
case self::TAG_GETUID:
$this->onResponse->executeOne($this, $ok, $this->decodeGetUniqueId($lines));
break;
case self::TAG_COUNT:
$this->onResponse->executeOne($this, $ok, $this->decodeCount($lines));
break;
case self::TAG_SIZE:
$this->onResponse->executeOne($this, $ok, $this->decodeSize($lines));
break;
case self::TAG_DELETEMESSAGE:
$this->expunge();
break;
case self::TAG_EXPUNGE:
$this->onResponse->executeOne($this, count($lines) - 1, $raw);
break;
case self::TAG_GETRAWMESSAGE:
$this->onResponse->executeOne($this, !empty($blob), $raw);
break;
case self::TAG_GETRAWHEADER:
$this->onResponse->executeOne($this, !empty($blob), $raw);
break;
case self::TAG_GETRAWCONTENT:
$this->onResponse->executeOne($this, !empty($blob), $raw);
break;
default:
$this->onResponse->executeOne($this, $ok, $raw);
break;
}
}