@@ -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; |
@@ -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. |
@@ -47,7 +47,7 @@ |
||
| 47 | 47 | $stringResponse = $this->getHttpVersion() . ' ' . $this->httpResponse . "\r\n"; |
| 48 | 48 | |
| 49 | 49 | foreach ($this->getHeaders() as $name => $content) { |
| 50 | - $stringResponse .= $name . ': '. $content . "\r\n"; |
|
| 50 | + $stringResponse .= $name . ': ' . $content . "\r\n"; |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | // No content to concatenate |
@@ -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 | |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | if (is_string($frame)) { |
| 59 | 59 | $len = BitManipulation::frameSize($frame); |
| 60 | 60 | |
| 61 | - if ($byteNumber < 0 || $byteNumber > ($len-1)) { |
|
| 61 | + if ($byteNumber < 0 || $byteNumber > ($len - 1)) { |
|
| 62 | 62 | throw new \InvalidArgumentException( |
| 63 | 63 | sprintf('The frame is only %s bytes larges but you tried to get the %sth byte.', $len, $byteNumber) |
| 64 | 64 | ); |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | $res = 0; |
| 167 | 167 | |
| 168 | 168 | // for each byte, getting ord |
| 169 | - for($i = 0; $i < $subStringLength; $i++) { |
|
| 169 | + for ($i = 0; $i < $subStringLength; $i++) { |
|
| 170 | 170 | $res <<= 8; |
| 171 | 171 | $res += ord($subString[$i]); |
| 172 | 172 | } |
@@ -92,13 +92,13 @@ |
||
| 92 | 92 | |
| 93 | 93 | public function setMessageHandler($messageHandler) |
| 94 | 94 | { |
| 95 | - if (!$messageHandler instanceof MessageHandlerInterface && !is_string($messageHandler)) { |
|
| 95 | + if (!$messageHandler instanceof MessageHandlerInterface && !is_string($messageHandler)) { |
|
| 96 | 96 | throw new \InvalidArgumentException('The message handler must be an instance of MessageHandlerInterface or a string.'); |
| 97 | 97 | } |
| 98 | 98 | if (is_string($messageHandler)) { |
| 99 | 99 | try { |
| 100 | 100 | $reflection = new \ReflectionClass($messageHandler); |
| 101 | - if(!$reflection->implementsInterface('Nekland\Woketo\Message\MessageHandlerInterface')) { |
|
| 101 | + if (!$reflection->implementsInterface('Nekland\Woketo\Message\MessageHandlerInterface')) { |
|
| 102 | 102 | throw new \InvalidArgumentException('The messageHandler must implement MessageHandlerInterface'); |
| 103 | 103 | } |
| 104 | 104 | } catch (\ReflectionException $e) { |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | |
| 84 | 84 | private function initListeners() |
| 85 | 85 | { |
| 86 | - $this->socketStream->on('data', function ($data) { |
|
| 86 | + $this->socketStream->on('data', function($data) { |
|
| 87 | 87 | $this->processData($data); |
| 88 | 88 | }); |
| 89 | 89 | $this->socketStream->on('error', [$this, 'error']); |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | $this->currentMessage = $message; |
| 125 | 125 | if ($this->currentMessage->isComplete()) { |
| 126 | 126 | // Sending the message through the woketo API. |
| 127 | - switch($this->currentMessage->getOpcode()) { |
|
| 127 | + switch ($this->currentMessage->getOpcode()) { |
|
| 128 | 128 | case Frame::OP_TEXT: |
| 129 | 129 | $this->handler->onMessage($this->currentMessage->getContent(), $this); |
| 130 | 130 | break; |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | |
| 137 | 137 | } else { |
| 138 | 138 | // We wait for more data so we start a timeout. |
| 139 | - $this->timeout = $this->loop->addTimer(Connection::DEFAULT_TIMEOUT, function () { |
|
| 139 | + $this->timeout = $this->loop->addTimer(Connection::DEFAULT_TIMEOUT, function() { |
|
| 140 | 140 | $this->messageProcessor->timeout($this->socketStream); |
| 141 | 141 | }); |
| 142 | 142 | } |
@@ -50,7 +50,7 @@ |
||
| 50 | 50 | } catch (IncompleteFrameException $e) { |
| 51 | 51 | return ''; // There is no more frame we can generate, the data is saved as buffer. |
| 52 | 52 | } |
| 53 | - } while(!$this->isComplete() && !empty($this->buffer)); |
|
| 53 | + } while (!$this->isComplete() && !empty($this->buffer)); |
|
| 54 | 54 | |
| 55 | 55 | if ($this->isComplete()) { |
| 56 | 56 | return $this->buffer; |
@@ -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; |
@@ -25,11 +25,11 @@ discard block |
||
| 25 | 25 | */ |
| 26 | 26 | class Frame |
| 27 | 27 | { |
| 28 | - const OP_CONTINUE = 0; |
|
| 29 | - const OP_TEXT = 1; |
|
| 30 | - const OP_BINARY = 2; |
|
| 31 | - const OP_CLOSE = 8; |
|
| 32 | - const OP_PING = 9; |
|
| 28 | + const OP_CONTINUE = 0; |
|
| 29 | + const OP_TEXT = 1; |
|
| 30 | + const OP_BINARY = 2; |
|
| 31 | + const OP_CLOSE = 8; |
|
| 32 | + const OP_PING = 9; |
|
| 33 | 33 | const OP_PONG = 10; |
| 34 | 34 | |
| 35 | 35 | // To understand codes, please refer to RFC: |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | */ |
| 131 | 131 | private $infoBytesLen; |
| 132 | 132 | |
| 133 | - public function __construct($data=null) |
|
| 133 | + public function __construct($data = null) |
|
| 134 | 134 | { |
| 135 | 135 | if (null !== $data) { |
| 136 | 136 | $this->setRawData($data); |
@@ -81,7 +81,7 @@ |
||
| 81 | 81 | $socket->end(); |
| 82 | 82 | $data = ''; |
| 83 | 83 | } |
| 84 | - } while(!empty($data)); |
|
| 84 | + } while (!empty($data)); |
|
| 85 | 85 | |
| 86 | 86 | return $messages; |
| 87 | 87 | } |