@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | // Data is now stored in the message, let's clean the variable to stop both loops. |
| 96 | 96 | $data = null; |
| 97 | 97 | } |
| 98 | - } while(!$message->isComplete() && !empty($data)); |
|
| 98 | + } while (!$message->isComplete() && !empty($data)); |
|
| 99 | 99 | |
| 100 | 100 | if ($message->isComplete()) { |
| 101 | 101 | $this->processHelper($message, $socket); |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | $socket->end(); |
| 119 | 119 | $data = ''; |
| 120 | 120 | } |
| 121 | - } while(!empty($data)); |
|
| 121 | + } while (!empty($data)); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | /** |
@@ -63,7 +63,7 @@ |
||
| 63 | 63 | public function add(string $name, $value) |
| 64 | 64 | { |
| 65 | 65 | if (!empty($this->headers[$name])) { |
| 66 | - if (!\is_array($this->headers[$name])){ |
|
| 66 | + if (!\is_array($this->headers[$name])) { |
|
| 67 | 67 | $this->headers[$name] = [$this->headers[$name]]; |
| 68 | 68 | } |
| 69 | 69 | $this->headers[$name][] = $value; |
@@ -38,7 +38,7 @@ |
||
| 38 | 38 | { |
| 39 | 39 | // Doesn't log everything in not debug context |
| 40 | 40 | if ($this->debug || \in_array($level, [LogLevel::CRITICAL, LogLevel::ERROR])) { |
| 41 | - echo '[' . date('Y-m-d H:i:s') . '][' . $level . '] ' . $message ."\n"; |
|
| 41 | + echo '[' . date('Y-m-d H:i:s') . '][' . $level . '] ' . $message . "\n"; |
|
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | } |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | * on the root directory of this project |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | -declare(strict_types=1); |
|
| 11 | +declare(strict_types = 1); |
|
| 12 | 12 | namespace Nekland\Woketo\Rfc6455; |
| 13 | 13 | |
| 14 | 14 | use Nekland\Woketo\Exception\Frame\ControlFrameException; |
@@ -26,11 +26,11 @@ discard block |
||
| 26 | 26 | */ |
| 27 | 27 | class Frame |
| 28 | 28 | { |
| 29 | - const OP_CONTINUE = 0; |
|
| 30 | - const OP_TEXT = 1; |
|
| 31 | - const OP_BINARY = 2; |
|
| 32 | - const OP_CLOSE = 8; |
|
| 33 | - const OP_PING = 9; |
|
| 29 | + const OP_CONTINUE = 0; |
|
| 30 | + const OP_TEXT = 1; |
|
| 31 | + const OP_BINARY = 2; |
|
| 32 | + const OP_CLOSE = 8; |
|
| 33 | + const OP_PING = 9; |
|
| 34 | 34 | const OP_PONG = 10; |
| 35 | 35 | |
| 36 | 36 | // To understand codes, please refer to RFC: |
@@ -588,7 +588,7 @@ discard block |
||
| 588 | 588 | { |
| 589 | 589 | $this->config = \array_merge([ |
| 590 | 590 | 'maxPayloadSize' => Frame::$defaultMaxPayloadSize, |
| 591 | - ],$config); |
|
| 591 | + ], $config); |
|
| 592 | 592 | |
| 593 | 593 | return $this; |
| 594 | 594 | } |
@@ -96,7 +96,7 @@ |
||
| 96 | 96 | |
| 97 | 97 | if (\count($explodingHeader)) { |
| 98 | 98 | unset($explodingHeader[0]); // removing the name of the extension |
| 99 | - foreach($explodingHeader as $variable) { |
|
| 99 | + foreach ($explodingHeader as $variable) { |
|
| 100 | 100 | $explodeVariable = \explode('=', $variable); |
| 101 | 101 | |
| 102 | 102 | // The value can be with or without quote. We need to remove extra quotes. |
@@ -69,10 +69,10 @@ discard block |
||
| 69 | 69 | |
| 70 | 70 | private function initListeners() |
| 71 | 71 | { |
| 72 | - $this->stream->on('data', function ($data) { |
|
| 72 | + $this->stream->on('data', function($data) { |
|
| 73 | 73 | $this->processData($data); |
| 74 | 74 | }); |
| 75 | - $this->stream->on('error', function ($data) { |
|
| 75 | + $this->stream->on('error', function($data) { |
|
| 76 | 76 | $this->error($data); |
| 77 | 77 | }); |
| 78 | 78 | } |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | $this->currentMessage = $message; |
| 115 | 115 | if ($this->currentMessage->isComplete()) { |
| 116 | 116 | // Sending the message through the woketo API. |
| 117 | - switch($this->currentMessage->getOpcode()) { |
|
| 117 | + switch ($this->currentMessage->getOpcode()) { |
|
| 118 | 118 | case Frame::OP_TEXT: |
| 119 | 119 | $this->getHandler()->onMessage($this->currentMessage->getContent(), $this); |
| 120 | 120 | break; |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | |
| 127 | 127 | } else { |
| 128 | 128 | // We wait for more data so we start a timeout. |
| 129 | - $this->timeout = $this->loop->addTimer(Connection::DEFAULT_TIMEOUT, function () { |
|
| 129 | + $this->timeout = $this->loop->addTimer(Connection::DEFAULT_TIMEOUT, function() { |
|
| 130 | 130 | $this->logger->notice('Connection to ' . $this->getIp() . ' timed out.'); |
| 131 | 131 | $this->messageProcessor->timeout($this->stream); |
| 132 | 132 | }); |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | $stringResponse = $this->getHttpVersion() . ' ' . $this->httpResponse . "\r\n"; |
| 99 | 99 | |
| 100 | 100 | foreach ($this->getHeaders() as $name => $content) { |
| 101 | - $stringResponse .= $name . ': '. $content . "\r\n"; |
|
| 101 | + $stringResponse .= $name . ': ' . $content . "\r\n"; |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | // No content to concatenate |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | { |
| 153 | 153 | $httpElements = \explode(' ', $firstLine); |
| 154 | 154 | |
| 155 | - if (!\preg_match('/HTTP\/[1-2\.]+/',$httpElements[0])) { |
|
| 155 | + if (!\preg_match('/HTTP\/[1-2\.]+/', $httpElements[0])) { |
|
| 156 | 156 | throw Response::createNotHttpException($firstLine); |
| 157 | 157 | } |
| 158 | 158 | $response->setHttpVersion($httpElements[0]); |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | |
| 32 | 32 | $key = ''; |
| 33 | 33 | for ($i = 0; $i < 16; $i++) {
|
| 34 | - $key .= chr(mt_rand(0,255)); |
|
| 34 | + $key .= chr(mt_rand(0, 255)); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | $key = base64_encode($key); |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | {
|
| 111 | 111 | $bytes = ''; |
| 112 | 112 | |
| 113 | - for($i = 0; $i < 16; $i++) {
|
|
| 113 | + for ($i = 0; $i < 16; $i++) {
|
|
| 114 | 114 | $bytes .= chr(mt_rand(0, 255)); |
| 115 | 115 | } |
| 116 | 116 | |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | * For the full license, take a look to the LICENSE file |
| 9 | 9 | * on the root directory of this project |
| 10 | 10 | */ |
| 11 | -declare(strict_types=1); |
|
| 11 | +declare(strict_types = 1); |
|
| 12 | 12 | |
| 13 | 13 | namespace Nekland\Woketo\Utils; |
| 14 | 14 | use Nekland\Woketo\Exception\Utils\NotLongEnoughException; |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | if (\is_string($frame)) { |
| 66 | 66 | $len = BitManipulation::frameSize($frame); |
| 67 | 67 | |
| 68 | - if ($byteNumber < 0 || $byteNumber > ($len-1)) { |
|
| 68 | + if ($byteNumber < 0 || $byteNumber > ($len - 1)) { |
|
| 69 | 69 | throw new \InvalidArgumentException( |
| 70 | 70 | \sprintf('The frame is only %s bytes larges but you tried to get the %sth byte.', $len, $byteNumber) |
| 71 | 71 | ); |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | $res = 0; |
| 174 | 174 | |
| 175 | 175 | // for each byte, getting ord |
| 176 | - for($i = 0; $i < $subStringLength; $i++) { |
|
| 176 | + for ($i = 0; $i < $subStringLength; $i++) { |
|
| 177 | 177 | $res <<= 8; |
| 178 | 178 | $res += \ord($subString[$i]); |
| 179 | 179 | } |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | $frame = "\0" . $frame; |
| 273 | 273 | } |
| 274 | 274 | |
| 275 | - switch(true) { |
|
| 275 | + switch (true) { |
|
| 276 | 276 | case $len <= 2: |
| 277 | 277 | $format = 'n'; |
| 278 | 278 | break; |