Skip to content

Fix english in no response message #100

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:
git fetch origin $TRAVIS_BRANCH;
fi
- git merge-base origin/$TRAVIS_BRANCH $TRAVIS_PULL_REQUEST_SHA || git fetch origin +refs/pull/$TRAVIS_PULL_REQUEST/merge --unshallow
- wget https://github.com/diff-sniffer/git/releases/download/0.1.0/git-phpcs.phar
- wget https://github.com/diff-sniffer/git/releases/download/0.2.0/git-phpcs.phar
- php git-phpcs.phar origin/$TRAVIS_BRANCH...$TRAVIS_PULL_REQUEST_SHA

# - stage: Code Quality
Expand Down
5 changes: 5 additions & 0 deletions src/Exception/QueryException.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,9 @@ public static function cannotInsertEmptyValues() : self
{
return new self('Inserting empty values array is not supported in ClickHouse');
}

public static function noResponse() : self
{
return new self('No response returned');
}
}
8 changes: 2 additions & 6 deletions src/Statement.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,14 +183,10 @@ public function isError()
return ($this->response()->http_code() !== 200 || $this->response()->error_no());
}

/**
* @return bool
* @throws Exception\TransportException
*/
private function check()
private function check() : bool
{
if (!$this->_request->isResponseExists()) {
throw new QueryException('Not have response');
throw QueryException::noResponse();
}

if ($this->isError()) {
Expand Down
32 changes: 14 additions & 18 deletions src/Transport/CurlerRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace ClickHouseDB\Transport;

use const CURLOPT_HTTPGET;
use const CURLOPT_POST;

class CurlerRequest
{
/**
Expand Down Expand Up @@ -44,14 +47,10 @@ class CurlerRequest
*/
private $handle;

/**
* @var CurlerResponse
*/
private $resp = null;
/** @var CurlerResponse */
private $response;

/**
* @var bool
*/
/** @var bool */
private $_persistent = false;

/**
Expand Down Expand Up @@ -616,24 +615,21 @@ private function execute($method)
*/
public function response()
{
if (!$this->resp) {
if (! $this->response) {
throw new \ClickHouseDB\Exception\TransportException('Can`t fetch response - is empty');
}

return $this->resp;
return $this->response;
}

/**
* @return bool
*/
public function isResponseExists()
public function isResponseExists() : bool
{
return ($this->resp ? true : false);
return $this->response !== null;
}

public function setResponse(CurlerResponse $response)
public function setResponse(CurlerResponse $response) : void
{
$this->resp = $response;
$this->response = $response;
}

/**
Expand Down Expand Up @@ -678,12 +674,12 @@ private function prepareRequest()


if (strtoupper($method) == 'GET') {
$curl_opt[CURLOPT_HTTPGET] = TRUE;
$curl_opt[CURLOPT_HTTPGET] = true;
$curl_opt[CURLOPT_CUSTOMREQUEST] = strtoupper($method);
$curl_opt[CURLOPT_POSTFIELDS] = false;
} else {
if (strtoupper($method) === 'POST') {
$curl_opt[CURLOPT_POST] = TRUE;
$curl_opt[CURLOPT_POST] = true;
}

$curl_opt[CURLOPT_CUSTOMREQUEST] = strtoupper($method);
Expand Down