@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | $result = ''; |
115 | 115 | } |
116 | 116 | |
117 | - if(strpos($line, self::RESPONSE_VERSION) !== false) { |
|
117 | + if (strpos($line, self::RESPONSE_VERSION) !== false) { |
|
118 | 118 | $results[] = $line; |
119 | 119 | $result = ''; |
120 | 120 | } |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | $result .= self::COMMAND_SEPARATOR; |
123 | 123 | } |
124 | 124 | |
125 | - if(!empty($result) && $result !== self::COMMAND_SEPARATOR) { |
|
125 | + if (!empty($result) && $result !== self::COMMAND_SEPARATOR) { |
|
126 | 126 | $results[] = $result; |
127 | 127 | } |
128 | 128 | |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | */ |
159 | 159 | public function createResponse($command, $data) |
160 | 160 | { |
161 | - switch($command) { |
|
161 | + switch ($command) { |
|
162 | 162 | case self::COMMAND_GET: |
163 | 163 | return new ReadResponse($data); |
164 | 164 | case self::COMMAND_SET: |
@@ -190,11 +190,11 @@ discard block |
||
190 | 190 | */ |
191 | 191 | public function createRequest($command, $args) |
192 | 192 | { |
193 | - if(!in_array($command, self::COMMANDS)) { |
|
193 | + if (!in_array($command, self::COMMANDS)) { |
|
194 | 194 | throw new WrongCommandException("Unknown command: $command"); |
195 | 195 | } |
196 | 196 | |
197 | - if(in_array($command, self::STORAGE_COMMANDS)) { |
|
197 | + if (in_array($command, self::STORAGE_COMMANDS)) { |
|
198 | 198 | return new StorageRequest($command, ...$args); |
199 | 199 | } |
200 | 200 |
@@ -13,7 +13,7 @@ |
||
13 | 13 | */ |
14 | 14 | public function parse() |
15 | 15 | { |
16 | - if(trim($this->data) !== Parser::RESPONSE_DELETED) { |
|
16 | + if (trim($this->data) !== Parser::RESPONSE_DELETED) { |
|
17 | 17 | $this->fail(); |
18 | 18 | } |
19 | 19 |
@@ -11,7 +11,7 @@ |
||
11 | 11 | */ |
12 | 12 | public function parse() |
13 | 13 | { |
14 | - if(trim($this->data) !== Parser::RESPONSE_OK) { |
|
14 | + if (trim($this->data) !== Parser::RESPONSE_OK) { |
|
15 | 15 | $this->fail(); |
16 | 16 | } |
17 | 17 |
@@ -16,7 +16,7 @@ |
||
16 | 16 | |
17 | 17 | foreach ($lines as $line) { |
18 | 18 | preg_match('/STAT (\w+) (\w+)/', $line, $matches); |
19 | - if(empty($matches)) { |
|
19 | + if (empty($matches)) { |
|
20 | 20 | break; |
21 | 21 | } |
22 | 22 |
@@ -13,7 +13,7 @@ |
||
13 | 13 | */ |
14 | 14 | public function parse() |
15 | 15 | { |
16 | - if(trim($this->data) !== Parser::RESPONSE_TOUCHED) { |
|
16 | + if (trim($this->data) !== Parser::RESPONSE_TOUCHED) { |
|
17 | 17 | $this->fail(); |
18 | 18 | } |
19 | 19 |
@@ -16,7 +16,7 @@ |
||
16 | 16 | |
17 | 17 | $value = isset($match[1]) ? trim($match[1]) : null; |
18 | 18 | |
19 | - if(null === $value) { |
|
19 | + if (null === $value) { |
|
20 | 20 | $this->fail(); |
21 | 21 | } |
22 | 22 |
@@ -13,7 +13,7 @@ |
||
13 | 13 | */ |
14 | 14 | public function parse() |
15 | 15 | { |
16 | - if($this->data === Parser::RESPONSE_NOT_FOUND) { |
|
16 | + if ($this->data === Parser::RESPONSE_NOT_FOUND) { |
|
17 | 17 | $this->fail(); |
18 | 18 | } |
19 | 19 |
@@ -11,7 +11,7 @@ |
||
11 | 11 | */ |
12 | 12 | public function parse() |
13 | 13 | { |
14 | - if(trim($this->data) !== Parser::RESPONSE_STORED) { |
|
14 | + if (trim($this->data) !== Parser::RESPONSE_STORED) { |
|
15 | 15 | $this->fail(); |
16 | 16 | } |
17 | 17 |
@@ -68,13 +68,13 @@ discard block |
||
68 | 68 | $this->stream = $stream; |
69 | 69 | $this->isConnecting = false; |
70 | 70 | |
71 | - $stream->on('data', function ($chunk) { |
|
71 | + $stream->on('data', function($chunk) { |
|
72 | 72 | $this->emit('data', [$chunk]); |
73 | 73 | }); |
74 | 74 | |
75 | 75 | $stream->on('close', [$this, 'close']); |
76 | 76 | |
77 | - while($this->queries) { |
|
77 | + while ($this->queries) { |
|
78 | 78 | $this->stream->write(array_shift($this->queries)); |
79 | 79 | } |
80 | 80 | } |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | |
88 | 88 | public function close() |
89 | 89 | { |
90 | - if($this->stream) { |
|
90 | + if ($this->stream) { |
|
91 | 91 | $this->stream->close(); |
92 | 92 | } |
93 | 93 | |
@@ -100,13 +100,13 @@ discard block |
||
100 | 100 | */ |
101 | 101 | public function write($query) |
102 | 102 | { |
103 | - if($this->stream && $this->stream->isWritable()) { |
|
103 | + if ($this->stream && $this->stream->isWritable()) { |
|
104 | 104 | $this->stream->write($query); |
105 | 105 | return; |
106 | 106 | } |
107 | 107 | |
108 | 108 | $this->queries[] = $query; |
109 | - if(!$this->isConnecting) { |
|
109 | + if (!$this->isConnecting) { |
|
110 | 110 | $this->connect(); |
111 | 111 | } |
112 | 112 | } |