本文整理匯總了PHP中Buzz\Message\Response::isSuccessful方法的典型用法代碼示例。如果您正苦於以下問題:PHP Response::isSuccessful方法的具體用法?PHP Response::isSuccessful怎麽用?PHP Response::isSuccessful使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Buzz\Message\Response
的用法示例。
在下文中一共展示了Response::isSuccessful方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: __construct
public function __construct(TransportResponse $response)
{
if (!$response->isSuccessful()) {
throw new TransportException($response);
}
$this->response = $response;
}
示例2: rev
public function rev(Response $response)
{
if ($response->isSuccessful()) {
return $this->decode($response->getHeader('Etag'));
}
throw new RugException('not_found', 'The specified document or revision cannot be found or has been deleted');
}
示例3: isSuccessful
public function isSuccessful()
{
if (parent::isSuccessful()) {
$result = $this->getArrayResult();
return !array_key_exists('error', $result);
}
return false;
}
示例4: doRequest
/**
* @param FormRequest $request
*
* @throws HttpException
*
* @return array
*/
protected function doRequest(FormRequest $request)
{
$request->setMethod('POST');
$request->fromUrl($this->getApiEndpoint());
$this->client->send($request, $response = new Response());
if (false == $response->isSuccessful()) {
throw HttpException::factory($request, $response);
}
$result = array();
parse_str($response->getContent(), $result);
foreach ($result as &$value) {
$value = urldecode($value);
}
return $result;
}
示例5: assertRequestIsSuccessful
/**
* @param \Buzz\Message\Response $response
* @throws \InvalidArgumentException
*/
private function assertRequestIsSuccessful(\Buzz\Message\Response $response)
{
$data = json_decode($response->getContent(), true);
if (!$response->isSuccessful() || !isset($data['success']) || $data['success'] != "true") {
//XXX Invent Exception fitting here
throw new \InvalidArgumentException($response->getContent());
}
}
示例6: getResult
/**
* @param \Buzz\Message\Response $response
*
* @throws HttpException if status not OK
* @throws HttpException if content not json
*
* @return \stdClass|\stdClass[]|null
*/
protected function getResult(Response $response)
{
if (false == $response->isSuccessful()) {
throw new HttpException($response->getStatusCode(), sprintf("The api call finished with status %s but it was expected 200. Response content:\n\n%s", $response->getStatusCode(), $response->getContent()));
}
$content = $response->getContent();
$result = null;
if (false == empty($content)) {
$result = json_decode($response->getContent());
if (null === $result) {
throw new LogicException(sprintf("The response status is successful but the content is not a valid json object:\n\n%s", $response->getContent()));
}
}
return $result;
}
示例7: handleResponse
/**
* @param Response $response
*
* @throws HttpException
*/
protected function handleResponse(Response $response)
{
if ($response->isSuccessful()) {
return;
}
$this->handleError($response);
}
示例8: isSuccessful
/**
* @return bool
*/
public function isSuccessful()
{
return $this->response->isSuccessful();
}