示例#1
0
文件: Swift.php 项目: jenia0jenia/otk
 /**
  * Throws an exception if the response code wanted does not match the one returned
  * @param Swift_Event_ResponseEvent The full response from the service
  * @param int The 3 digit response code wanted
  * @throws Swift_BadResponseException If the code does not match
  */
 protected function assertCorrectResponse(Swift_Events_ResponseEvent $response, $codes)
 {
     $codes = (array) $codes;
     if (!in_array($response->getCode(), $codes)) {
         $log = Swift_LogContainer::getLog();
         $error = "Expected response code(s) [" . implode(", ", $codes) . "] but got response [" . $response->getString() . "]";
         if ($log->hasLevel(Swift_Log::LOG_ERRORS)) {
             $log->add($error, Swift_Log::ERROR);
         }
         throw new Swift_BadResponseException($error);
     }
 }
 /**
  * Response listener method
  * @param Swift_Events_ResponseEvent The event occured in Swift
  */
 public function responseReceived(Swift_Events_ResponseEvent $e)
 {
     $this->target->lastResponse = $e->getString();
     $this->target->responseCode = $e->getCode();
 }