@@ -120,10 +120,10 @@ discard block |
||
| 120 | 120 | $proto = 'https'; |
| 121 | 121 | } |
| 122 | 122 | $uri = $proto . '://' . $this->_host; |
| 123 | - if (stripos($this->_host,'/')!==false || stripos($this->_host,':')!==false) { |
|
| 123 | + if (stripos($this->_host, '/') !== false || stripos($this->_host, ':') !== false) { |
|
| 124 | 124 | return $uri; |
| 125 | 125 | } |
| 126 | - if (intval($this->_port)>0) { |
|
| 126 | + if (intval($this->_port) > 0) { |
|
| 127 | 127 | return $uri . ':' . $this->_port; |
| 128 | 128 | } |
| 129 | 129 | return $uri; |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | $new->timeOut($this->settings()->getTimeOut()); |
| 198 | - $new->connectTimeOut($this->_connectTimeOut);//->keepAlive(); // one sec |
|
| 198 | + $new->connectTimeOut($this->_connectTimeOut); //->keepAlive(); // one sec |
|
| 199 | 199 | $new->verbose(boolval($this->_verbose)); |
| 200 | 200 | |
| 201 | 201 | return $new; |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | { |
| 249 | 249 | |
| 250 | 250 | if ($sql instanceof Query) { |
| 251 | - $query=$sql; |
|
| 251 | + $query = $sql; |
|
| 252 | 252 | } else { |
| 253 | 253 | $query = new Query($sql); |
| 254 | 254 | } |
@@ -610,10 +610,10 @@ discard block |
||
| 610 | 610 | * @return Statement |
| 611 | 611 | * @throws \ClickHouseDB\Exception\TransportException |
| 612 | 612 | */ |
| 613 | - private function streaming(Stream $streamRW,CurlerRequest $request) |
|
| 613 | + private function streaming(Stream $streamRW, CurlerRequest $request) |
|
| 614 | 614 | { |
| 615 | - $callable=$streamRW->getClosure(); |
|
| 616 | - $stream=$streamRW->getStream(); |
|
| 615 | + $callable = $streamRW->getClosure(); |
|
| 616 | + $stream = $streamRW->getStream(); |
|
| 617 | 617 | |
| 618 | 618 | |
| 619 | 619 | |
@@ -624,11 +624,11 @@ discard block |
||
| 624 | 624 | if ($streamRW->isWrite()) |
| 625 | 625 | { |
| 626 | 626 | |
| 627 | - $callable = function ($ch, $fd, $length) use ($stream) { |
|
| 627 | + $callable = function($ch, $fd, $length) use ($stream) { |
|
| 628 | 628 | return ($line = fread($stream, $length)) ? $line : ''; |
| 629 | 629 | }; |
| 630 | 630 | } else { |
| 631 | - $callable = function ($ch, $fd) use ($stream) { |
|
| 631 | + $callable = function($ch, $fd) use ($stream) { |
|
| 632 | 632 | return fwrite($stream, $fd); |
| 633 | 633 | }; |
| 634 | 634 | } |
@@ -663,7 +663,7 @@ discard block |
||
| 663 | 663 | } |
| 664 | 664 | |
| 665 | 665 | |
| 666 | - $this->_curler->execOne($request,true); |
|
| 666 | + $this->_curler->execOne($request, true); |
|
| 667 | 667 | $response = new Statement($request); |
| 668 | 668 | if ($response->isError()) { |
| 669 | 669 | $response->error(); |
@@ -685,11 +685,11 @@ discard block |
||
| 685 | 685 | * @return Statement |
| 686 | 686 | * @throws \ClickHouseDB\Exception\TransportException |
| 687 | 687 | */ |
| 688 | - public function streamRead(Stream $streamRead,$sql,$bindings=[]) |
|
| 688 | + public function streamRead(Stream $streamRead, $sql, $bindings = []) |
|
| 689 | 689 | { |
| 690 | - $sql=$this->prepareQuery($sql,$bindings); |
|
| 691 | - $request=$this->getRequestRead($sql); |
|
| 692 | - return $this->streaming($streamRead,$request); |
|
| 690 | + $sql = $this->prepareQuery($sql, $bindings); |
|
| 691 | + $request = $this->getRequestRead($sql); |
|
| 692 | + return $this->streaming($streamRead, $request); |
|
| 693 | 693 | |
| 694 | 694 | } |
| 695 | 695 | |
@@ -700,10 +700,10 @@ discard block |
||
| 700 | 700 | * @return Statement |
| 701 | 701 | * @throws \ClickHouseDB\Exception\TransportException |
| 702 | 702 | */ |
| 703 | - public function streamWrite(Stream $streamWrite,$sql,$bindings=[]) |
|
| 703 | + public function streamWrite(Stream $streamWrite, $sql, $bindings = []) |
|
| 704 | 704 | { |
| 705 | - $sql=$this->prepareQuery($sql,$bindings); |
|
| 705 | + $sql = $this->prepareQuery($sql, $bindings); |
|
| 706 | 706 | $request = $this->writeStreamData($sql); |
| 707 | - return $this->streaming($streamWrite,$request); |
|
| 707 | + return $this->streaming($streamWrite, $request); |
|
| 708 | 708 | } |
| 709 | 709 | } |
@@ -75,7 +75,7 @@ |
||
| 75 | 75 | $markers = $this->bindings; |
| 76 | 76 | |
| 77 | 77 | // ------ if/else conditions & if[set|int]/else conditions ----- |
| 78 | - $sql = preg_replace_callback('#\{if(.{0,}?)\s([^\}]+?)}([^\{]+?)(\{else\}([^\{]+?)?)?\s*\{\/if}#sui', function ($matches) use ($markers) { |
|
| 78 | + $sql = preg_replace_callback('#\{if(.{0,}?)\s([^\}]+?)}([^\{]+?)(\{else\}([^\{]+?)?)?\s*\{\/if}#sui', function($matches) use ($markers) { |
|
| 79 | 79 | return self::__ifsets($matches, $markers); |
| 80 | 80 | } |
| 81 | 81 | , $sql); |
@@ -63,19 +63,19 @@ discard block |
||
| 63 | 63 | */ |
| 64 | 64 | public function __construct(array $connectParams, array $settings = []) |
| 65 | 65 | { |
| 66 | - if (! isset($connectParams['username'])) { |
|
| 66 | + if (!isset($connectParams['username'])) { |
|
| 67 | 67 | throw new \InvalidArgumentException('not set username'); |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - if (! isset($connectParams['password'])) { |
|
| 70 | + if (!isset($connectParams['password'])) { |
|
| 71 | 71 | throw new \InvalidArgumentException('not set password'); |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - if (! isset($connectParams['port'])) { |
|
| 74 | + if (!isset($connectParams['port'])) { |
|
| 75 | 75 | throw new \InvalidArgumentException('not set port'); |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - if (! isset($connectParams['host'])) { |
|
| 78 | + if (!isset($connectParams['host'])) { |
|
| 79 | 79 | throw new \InvalidArgumentException('not set host'); |
| 80 | 80 | } |
| 81 | 81 | |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | |
| 97 | 97 | // apply settings to transport class |
| 98 | 98 | $this->settings()->database('default'); |
| 99 | - if (! empty($settings)) { |
|
| 99 | + if (!empty($settings)) { |
|
| 100 | 100 | $this->settings()->apply($settings); |
| 101 | 101 | } |
| 102 | 102 | |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | */ |
| 199 | 199 | public function transport() |
| 200 | 200 | { |
| 201 | - if (! $this->transport) { |
|
| 201 | + if (!$this->transport) { |
|
| 202 | 202 | throw new \InvalidArgumentException('Empty transport class'); |
| 203 | 203 | } |
| 204 | 204 | |
@@ -267,8 +267,8 @@ discard block |
||
| 267 | 267 | */ |
| 268 | 268 | public function useSession(string $useSessionId = null) |
| 269 | 269 | { |
| 270 | - if (! $this->settings()->getSessionId()) { |
|
| 271 | - if (! $useSessionId) { |
|
| 270 | + if (!$this->settings()->getSessionId()) { |
|
| 271 | + if (!$useSessionId) { |
|
| 272 | 272 | $this->settings()->makeSessionId(); |
| 273 | 273 | } else { |
| 274 | 274 | $this->settings()->session_id($useSessionId); |
@@ -386,14 +386,14 @@ discard block |
||
| 386 | 386 | */ |
| 387 | 387 | public function progressFunction(callable $callback) |
| 388 | 388 | { |
| 389 | - if (! is_callable($callback)) { |
|
| 389 | + if (!is_callable($callback)) { |
|
| 390 | 390 | throw new \InvalidArgumentException('Not is_callable progressFunction'); |
| 391 | 391 | } |
| 392 | 392 | |
| 393 | - if (! $this->settings()->is('send_progress_in_http_headers')) { |
|
| 393 | + if (!$this->settings()->is('send_progress_in_http_headers')) { |
|
| 394 | 394 | $this->settings()->set('send_progress_in_http_headers', 1); |
| 395 | 395 | } |
| 396 | - if (! $this->settings()->is('http_headers_progress_interval_ms')) { |
|
| 396 | + if (!$this->settings()->is('http_headers_progress_interval_ms')) { |
|
| 397 | 397 | $this->settings()->set('http_headers_progress_interval_ms', 100); |
| 398 | 398 | } |
| 399 | 399 | |
@@ -574,14 +574,14 @@ discard block |
||
| 574 | 574 | throw new QueryException('Queue must be empty, before insertBatch, need executeAsync'); |
| 575 | 575 | } |
| 576 | 576 | |
| 577 | - if (! in_array($format, self::SUPPORTED_FORMATS, true)) { |
|
| 577 | + if (!in_array($format, self::SUPPORTED_FORMATS, true)) { |
|
| 578 | 578 | throw new QueryException('Format not support in insertBatchFiles'); |
| 579 | 579 | } |
| 580 | 580 | |
| 581 | 581 | $result = []; |
| 582 | 582 | |
| 583 | 583 | foreach ($fileNames as $fileName) { |
| 584 | - if (! is_file($fileName) || ! is_readable($fileName)) { |
|
| 584 | + if (!is_file($fileName) || !is_readable($fileName)) { |
|
| 585 | 585 | throw new QueryException('Cant read file: ' . $fileName . ' ' . (is_file($fileName) ? '' : ' is not file')); |
| 586 | 586 | } |
| 587 | 587 | |
@@ -598,7 +598,7 @@ discard block |
||
| 598 | 598 | |
| 599 | 599 | // fetch resutl |
| 600 | 600 | foreach ($fileNames as $fileName) { |
| 601 | - if (! $result[$fileName]->isError()) { |
|
| 601 | + if (!$result[$fileName]->isError()) { |
|
| 602 | 602 | continue; |
| 603 | 603 | } |
| 604 | 604 | |
@@ -621,7 +621,7 @@ discard block |
||
| 621 | 621 | throw new QueryException('Queue must be empty, before insertBatch, need executeAsync'); |
| 622 | 622 | } |
| 623 | 623 | |
| 624 | - if (! in_array($format, self::SUPPORTED_FORMATS, true)) { |
|
| 624 | + if (!in_array($format, self::SUPPORTED_FORMATS, true)) { |
|
| 625 | 625 | throw new QueryException('Format not support in insertBatchFiles'); |
| 626 | 626 | } |
| 627 | 627 | |