@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | $event = new ReadEvent( |
114 | 114 | $executor, |
115 | 115 | $socket, |
116 | - $meta[ RequestExecutorInterface::META_USER_CONTEXT ], |
|
116 | + $meta[RequestExecutorInterface::META_USER_CONTEXT], |
|
117 | 117 | $frame, |
118 | 118 | true |
119 | 119 | ); |
@@ -140,8 +140,7 @@ discard block |
||
140 | 140 | if (!$counter) { |
141 | 141 | $meta = $descriptor->getMetadata(); |
142 | 142 | $counter = new SpeedRateCounter($minRate, $duration); |
143 | - $time = $meta[RequestExecutorInterface::META_LAST_IO_START_TIME] ?: |
|
144 | - $meta[RequestExecutorInterface::META_CONNECTION_FINISH_TIME]; |
|
143 | + $time = $meta[RequestExecutorInterface::META_LAST_IO_START_TIME] ?: $meta[RequestExecutorInterface::META_CONNECTION_FINISH_TIME]; |
|
145 | 144 | $counter->advance($time, 0); |
146 | 145 | $descriptor->registerCounter($name, $counter); |
147 | 146 | } |
@@ -204,26 +203,26 @@ discard block |
||
204 | 203 | $map = [ |
205 | 204 | RequestDescriptor::COUNTER_RECV_MIN_RATE => [ |
206 | 205 | 'resetCounter' => RequestDescriptor::COUNTER_SEND_MIN_RATE, |
207 | - 'minSpeed' => $meta[ RequestExecutorInterface::META_MIN_RECEIVE_SPEED ], |
|
208 | - 'duration' => $meta[ RequestExecutorInterface::META_MIN_RECEIVE_SPEED_DURATION ], |
|
206 | + 'minSpeed' => $meta[RequestExecutorInterface::META_MIN_RECEIVE_SPEED], |
|
207 | + 'duration' => $meta[RequestExecutorInterface::META_MIN_RECEIVE_SPEED_DURATION], |
|
209 | 208 | 'bytesCounter' => RequestExecutorInterface::META_BYTES_RECEIVED, |
210 | 209 | 'speedCounter' => RequestExecutorInterface::META_RECEIVE_SPEED, |
211 | - 'exception' => [ 'AsyncSockets\Exception\SlowSpeedTransferException', 'tooSlowDataReceiving' ], |
|
210 | + 'exception' => ['AsyncSockets\Exception\SlowSpeedTransferException', 'tooSlowDataReceiving'], |
|
212 | 211 | ], |
213 | 212 | RequestDescriptor::COUNTER_SEND_MIN_RATE => [ |
214 | 213 | 'resetCounter' => RequestDescriptor::COUNTER_RECV_MIN_RATE, |
215 | - 'minSpeed' => $meta[ RequestExecutorInterface::META_MIN_SEND_SPEED ], |
|
216 | - 'duration' => $meta[ RequestExecutorInterface::META_MIN_SEND_SPEED_DURATION ], |
|
214 | + 'minSpeed' => $meta[RequestExecutorInterface::META_MIN_SEND_SPEED], |
|
215 | + 'duration' => $meta[RequestExecutorInterface::META_MIN_SEND_SPEED_DURATION], |
|
217 | 216 | 'bytesCounter' => RequestExecutorInterface::META_BYTES_SENT, |
218 | 217 | 'speedCounter' => RequestExecutorInterface::META_SEND_SPEED, |
219 | - 'exception' => [ 'AsyncSockets\Exception\SlowSpeedTransferException', 'tooSlowDataSending' ], |
|
218 | + 'exception' => ['AsyncSockets\Exception\SlowSpeedTransferException', 'tooSlowDataSending'], |
|
220 | 219 | ], |
221 | 220 | ]; |
222 | 221 | |
223 | - if (!isset($map[ $name ])) { |
|
224 | - throw new \LogicException('Can not process counter ' . $name . ' in transfer operation'); |
|
222 | + if (!isset($map[$name])) { |
|
223 | + throw new \LogicException('Can not process counter '.$name.' in transfer operation'); |
|
225 | 224 | } |
226 | 225 | |
227 | - return $map[ $name ]; |
|
226 | + return $map[$name]; |
|
228 | 227 | } |
229 | 228 | } |
@@ -52,8 +52,7 @@ discard block |
||
52 | 52 | $this->verifySendResult('', stream_socket_sendto($resource, '')); |
53 | 53 | |
54 | 54 | $written = $isOutOfBand ? |
55 | - $this->writeOobData($resource, $data) : |
|
56 | - fwrite($resource, $data, strlen($data)); |
|
55 | + $this->writeOobData($resource, $data) : fwrite($resource, $data, strlen($data)); |
|
57 | 56 | |
58 | 57 | $this->verifySendResult($data, $written); |
59 | 58 | |
@@ -74,7 +73,7 @@ discard block |
||
74 | 73 | if ($sendResult === false || $sendResult < 0) { |
75 | 74 | throw new SendDataException( |
76 | 75 | $this->socket, |
77 | - trim('Failed to send data. ' . $this->getLastPhpErrorMessage()) |
|
76 | + trim('Failed to send data. '.$this->getLastPhpErrorMessage()) |
|
78 | 77 | ); |
79 | 78 | } |
80 | 79 | |
@@ -148,7 +147,7 @@ discard block |
||
148 | 147 | if ($data === false) { |
149 | 148 | throw new RecvDataException( |
150 | 149 | $this->socket, |
151 | - trim('Failed to read data. ' . $this->getLastPhpErrorMessage()) |
|
150 | + trim('Failed to read data. '.$this->getLastPhpErrorMessage()) |
|
152 | 151 | ); |
153 | 152 | } |
154 | 153 | |
@@ -202,9 +201,8 @@ discard block |
||
202 | 201 | private function resolveReadAttempts(array $context, $currentAttempts) |
203 | 202 | { |
204 | 203 | return ($context['countCycles'] === 1 && empty($context['dataBeforeIo'])) || |
205 | - ($context['countCycles'] > 1 && $context['isStreamDataEmpty']) ? |
|
206 | - $currentAttempts - 1 : |
|
207 | - self::READ_ATTEMPTS; |
|
204 | + ($context['countCycles'] > 1 && $context['isStreamDataEmpty']) ? |
|
205 | + $currentAttempts - 1 : self::READ_ATTEMPTS; |
|
208 | 206 | |
209 | 207 | } |
210 | 208 |