1 | <?php |
||
0 ignored issues
–
show
introduced
by
![]() |
|||
2 | |||
3 | namespace ClickHouseDB\Transport; |
||
4 | |||
5 | use ClickHouseDB\Statement; |
||
6 | |||
7 | /** |
||
8 | * Class StreamInsert |
||
0 ignored issues
–
show
|
|||
9 | * @deprecated |
||
0 ignored issues
–
show
|
|||
10 | * @package ClickHouseDB\Transport |
||
0 ignored issues
–
show
|
|||
11 | */ |
||
12 | class StreamInsert |
||
13 | { |
||
14 | /** |
||
0 ignored issues
–
show
|
|||
15 | * @var resource |
||
16 | */ |
||
17 | private $source; |
||
18 | |||
19 | /** |
||
0 ignored issues
–
show
|
|||
20 | * @var CurlerRequest |
||
21 | */ |
||
22 | private $request; |
||
23 | |||
24 | /** |
||
0 ignored issues
–
show
|
|||
25 | * @var CurlerRolling |
||
26 | */ |
||
27 | private $curlerRolling; |
||
28 | |||
29 | /** |
||
30 | * @param resource $source |
||
0 ignored issues
–
show
|
|||
31 | * @param CurlerRequest $request |
||
0 ignored issues
–
show
|
|||
32 | * @param CurlerRolling|null $curlerRolling |
||
33 | */ |
||
34 | 4 | public function __construct($source, CurlerRequest $request, $curlerRolling=null) |
|
0 ignored issues
–
show
|
|||
35 | { |
||
36 | 4 | if (!is_resource($source)) { |
|
0 ignored issues
–
show
|
|||
37 | throw new \InvalidArgumentException('Argument $source must be resource'); |
||
0 ignored issues
–
show
|
|||
38 | } |
||
39 | 4 | if ($curlerRolling instanceof CurlerRolling) |
|
0 ignored issues
–
show
|
|||
40 | { |
||
41 | 3 | $this->curlerRolling = $curlerRolling; |
|
42 | } else { |
||
43 | 1 | $this->curlerRolling = new CurlerRolling(); |
|
44 | } |
||
45 | 4 | $this->source = $source; |
|
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line. To visualize $a = "a";
$ab = "ab";
$abc = "abc";
will produce issues in the first and second line, while this second example $a = "a";
$ab = "ab";
$abc = "abc";
will produce no issues. ![]() |
|||
46 | 4 | $this->request = $request; |
|
47 | 4 | } |
|
48 | |||
49 | /** |
||
50 | * @param callable $callback function for stream read data |
||
0 ignored issues
–
show
|
|||
51 | * @return \ClickHouseDB\Statement |
||
0 ignored issues
–
show
|
|||
52 | * @throws \Exception |
||
0 ignored issues
–
show
|
|||
53 | */ |
||
54 | 4 | public function insert($callback) |
|
0 ignored issues
–
show
|
|||
55 | { |
||
56 | try { |
||
57 | 4 | if (!is_callable($callback)) { |
|
0 ignored issues
–
show
|
|||
58 | 2 | throw new \InvalidArgumentException('Argument $callback can not be called as a function'); |
|
0 ignored issues
–
show
|
|||
59 | } |
||
60 | |||
61 | // |
||
0 ignored issues
–
show
|
|||
62 | 2 | $this->request->header('Transfer-Encoding', 'chunked'); |
|
63 | 2 | $this->request->setReadFunction($callback); |
|
64 | 2 | $this->curlerRolling->execOne($this->request, true); |
|
65 | 2 | $statement = new Statement($this->request); |
|
66 | 2 | $statement->error(); |
|
67 | 2 | return $statement; |
|
0 ignored issues
–
show
|
|||
68 | } finally { |
||
69 | 4 | fclose($this->source); |
|
0 ignored issues
–
show
|
|||
70 | } |
||
71 | } |
||
72 | } |
||
73 |