@@ -9,7 +9,7 @@ |
||
9 | 9 | class StreamWrite extends Stream |
10 | 10 | { |
11 | 11 | |
12 | - public function __construct( $source) |
|
12 | + public function __construct($source) |
|
13 | 13 | { |
14 | 14 | |
15 | 15 | parent::__construct($source); |
@@ -31,7 +31,7 @@ |
||
31 | 31 | * @param CurlerRequest $request |
32 | 32 | * @param CurlerRolling|null $curlerRolling |
33 | 33 | */ |
34 | - public function __construct($source, CurlerRequest $request, $curlerRolling=null) |
|
34 | + public function __construct($source, CurlerRequest $request, $curlerRolling = null) |
|
35 | 35 | { |
36 | 36 | if (!is_resource($source)) { |
37 | 37 | throw new \InvalidArgumentException('Argument $source must be resource'); |
@@ -293,7 +293,7 @@ |
||
293 | 293 | |
294 | 294 | if (stripos($format, 'json') !== false) |
295 | 295 | { |
296 | - if (stripos($format,'JSONEachRow')===false) |
|
296 | + if (stripos($format, 'JSONEachRow') === false) |
|
297 | 297 | return $this->json(); |
298 | 298 | } |
299 | 299 | return $this->body(); |
@@ -15,11 +15,11 @@ discard block |
||
15 | 15 | /** |
16 | 16 | * @var bool |
17 | 17 | */ |
18 | - private $gzip=false; |
|
18 | + private $gzip = false; |
|
19 | 19 | /** |
20 | 20 | * @var null|callable |
21 | 21 | */ |
22 | - private $callable=null; |
|
22 | + private $callable = null; |
|
23 | 23 | /** |
24 | 24 | * @param resource $source |
25 | 25 | */ |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | */ |
61 | 61 | public function closure(callable $callable) |
62 | 62 | { |
63 | - $this->callable=$callable; |
|
63 | + $this->callable = $callable; |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | */ |
69 | 69 | public function enableGzipHeader() |
70 | 70 | { |
71 | - $this->gzip=true; |
|
71 | + $this->gzip = true; |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | } |
@@ -56,10 +56,10 @@ discard block |
||
56 | 56 | * @param string $pattern |
57 | 57 | * @return string |
58 | 58 | */ |
59 | - public function compile_binds($sql, $binds,$pattern) |
|
59 | + public function compile_binds($sql, $binds, $pattern) |
|
60 | 60 | { |
61 | 61 | return preg_replace_callback($pattern, function($m) use ($binds){ |
62 | - if(isset($binds[$m[1]])){ // If it exists in our array |
|
62 | + if (isset($binds[$m[1]])) { // If it exists in our array |
|
63 | 63 | return $binds[$m[1]]; // Then replace it from our array |
64 | 64 | } |
65 | 65 | |
@@ -75,14 +75,14 @@ discard block |
||
75 | 75 | */ |
76 | 76 | public function process($sql) |
77 | 77 | { |
78 | - $bindFormatted=[]; |
|
79 | - $bindRaw=[]; |
|
78 | + $bindFormatted = []; |
|
79 | + $bindRaw = []; |
|
80 | 80 | foreach ($this->bindings as $key => $value) { |
81 | 81 | if (is_array($value)) { |
82 | 82 | $valueSet = implode(', ', $value); |
83 | 83 | |
84 | 84 | $values = array_map( |
85 | - function ($value) { |
|
85 | + function($value) { |
|
86 | 86 | return ValueFormatter::formatValue($value); |
87 | 87 | }, |
88 | 88 | $value |
@@ -95,21 +95,21 @@ discard block |
||
95 | 95 | } |
96 | 96 | |
97 | 97 | if ($formattedParameter !== null) { |
98 | - $bindFormatted[$key]=$formattedParameter; |
|
98 | + $bindFormatted[$key] = $formattedParameter; |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | if ($valueSet !== null) { |
102 | - $bindRaw[$key]=$valueSet; |
|
102 | + $bindRaw[$key] = $valueSet; |
|
103 | 103 | } |
104 | 104 | } |
105 | 105 | |
106 | - for ($loop=0;$loop<2;$loop++) |
|
106 | + for ($loop = 0; $loop < 2; $loop++) |
|
107 | 107 | { |
108 | 108 | // dipping in binds |
109 | 109 | // example ['A' => '{B}' , 'B'=>':C','C'=>123] |
110 | - $sql=$this->compile_binds($sql,$bindRaw,'#{([\w+]+)}#'); |
|
110 | + $sql = $this->compile_binds($sql, $bindRaw, '#{([\w+]+)}#'); |
|
111 | 111 | } |
112 | - $sql=$this->compile_binds($sql,$bindFormatted,'#:([\w+]+)#'); |
|
112 | + $sql = $this->compile_binds($sql, $bindFormatted, '#:([\w+]+)#'); |
|
113 | 113 | |
114 | 114 | return $sql; |
115 | 115 | } |
@@ -80,8 +80,8 @@ |
||
80 | 80 | // Elements of the array - the numbers are formatted as usual, and the dates, dates-with-time, and lines are in |
81 | 81 | // single quotation marks with the same screening rules as above. |
82 | 82 | // as in the TabSeparated format, and then the resulting string is output in InsertRow in double quotes. |
83 | - $value = array_map( |
|
84 | - function ($v) use ($enclosure_esc, $encode_esc) { |
|
83 | + $value = array_map( |
|
84 | + function($v) use ($enclosure_esc, $encode_esc) { |
|
85 | 85 | return is_string($v) ? $this->encodeString($v, $enclosure_esc, $encode_esc) : $v; |
86 | 86 | }, |
87 | 87 | $value |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | */ |
238 | 238 | public function setWriteFunction($callback) |
239 | 239 | { |
240 | - $this->options[CURLOPT_WRITEFUNCTION]=$callback; |
|
240 | + $this->options[CURLOPT_WRITEFUNCTION] = $callback; |
|
241 | 241 | } |
242 | 242 | /** |
243 | 243 | * @param callable $callback |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | */ |
613 | 613 | public function response() |
614 | 614 | { |
615 | - if (! $this->response) { |
|
615 | + if (!$this->response) { |
|
616 | 616 | throw new \ClickHouseDB\Exception\TransportException('Can`t fetch response - is empty'); |
617 | 617 | } |
618 | 618 | |
@@ -708,7 +708,7 @@ discard block |
||
708 | 708 | |
709 | 709 | if (!empty($curl_opt[CURLOPT_WRITEFUNCTION])) |
710 | 710 | { |
711 | - $curl_opt[CURLOPT_HEADER]=false; |
|
711 | + $curl_opt[CURLOPT_HEADER] = false; |
|
712 | 712 | } |
713 | 713 | |
714 | 714 | if ($this->resultFileHandle) { |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | */ |
23 | 23 | private $degenerations = []; |
24 | 24 | |
25 | - private $supportFormats=[ |
|
25 | + private $supportFormats = [ |
|
26 | 26 | "FORMAT\\s+TSVRaw", |
27 | 27 | "FORMAT\\s+TSVWithNamesAndTypes", |
28 | 28 | "FORMAT\\s+TSVWithNames", |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | if (null === $this->format) { |
72 | 72 | return false; |
73 | 73 | } |
74 | - $supportFormats = implode("|",$this->supportFormats); |
|
74 | + $supportFormats = implode("|", $this->supportFormats); |
|
75 | 75 | |
76 | 76 | $matches = []; |
77 | 77 | if (preg_match_all('%(' . $supportFormats . ')%ius', $this->sql, $matches)) { |
@@ -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 |