Completed
Push — master ( e26ab3...1dd3f4 )
by Maxime
9s
created
src/Client/Connection.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@
 block discarded – undo
47 47
     }
48 48
 
49 49
     /**
50
-     * @param \Exception|string $error
50
+     * @param \Exception $error
51 51
      */
52 52
     private function onError($error)
53 53
     {
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -52,17 +52,17 @@  discard block
 block discarded – undo
52 52
         $this->buffer = '';
53 53
         $this->handler = $handler;
54 54
 
55
-        $clientPromise->then(function (Stream $stream) {
55
+        $clientPromise->then(function(Stream $stream) {
56 56
             $this->stream = $stream;
57 57
             $this->onConnection($stream);
58
-        }, function (\Exception $error){
58
+        }, function(\Exception $error) {
59 59
             $this->onError($error);
60 60
         });
61 61
     }
62 62
 
63 63
     private function onConnection(Stream $stream)
64 64
     {
65
-        $stream->on('data', function (string $data) {
65
+        $stream->on('data', function(string $data) {
66 66
             $this->onMessage($data);
67 67
         });
68 68
 
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 
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
 block discarded – undo
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->getLogger()->notice('Connection to ' . $this->getIp() . ' timed out.');
131 131
                     $this->messageProcessor->timeout($this->stream);
132 132
                 });
Please login to merge, or discard this patch.
Unused Use Statements   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -12,18 +12,18 @@
 block discarded – undo
12 12
 namespace Nekland\Woketo\Client;
13 13
 
14 14
 
15
-use Nekland\Woketo\Core\AbstractConnection;
16
-use Nekland\Woketo\Exception\Http\IncompleteHttpMessageException;
17
-use Nekland\Woketo\Exception\RuntimeException;
18
-use Nekland\Woketo\Exception\WebsocketException;
19
-use Nekland\Woketo\Http\Response;
20
-use Nekland\Woketo\Http\Url;
21
-use Nekland\Woketo\Message\MessageHandlerInterface;
22
-use Nekland\Woketo\Rfc6455\Frame;
23
-use Nekland\Woketo\Rfc6455\Handshake\ClientHandshake;
24
-use Nekland\Woketo\Rfc6455\MessageProcessor;
25
-use React\EventLoop\LoopInterface;
26
-use React\Promise\PromiseInterface;
15
+use Nekland\Woketo\Core\AbstractConnection;
16
+use Nekland\Woketo\Exception\Http\IncompleteHttpMessageException;
17
+use Nekland\Woketo\Exception\RuntimeException;
18
+use Nekland\Woketo\Exception\WebsocketException;
19
+use Nekland\Woketo\Http\Response;
20
+use Nekland\Woketo\Http\Url;
21
+use Nekland\Woketo\Message\MessageHandlerInterface;
22
+use Nekland\Woketo\Rfc6455\Frame;
23
+use Nekland\Woketo\Rfc6455\Handshake\ClientHandshake;
24
+use Nekland\Woketo\Rfc6455\MessageProcessor;
25
+use React\EventLoop\LoopInterface;
26
+use React\Promise\PromiseInterface;
27 27
 use React\Stream\Stream;
28 28
 
29 29
 class Connection extends AbstractConnection
Please login to merge, or discard this patch.
src/Server/Connection.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -69,10 +69,10 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
                 });
Please login to merge, or discard this patch.
src/Http/Response.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
         $stringResponse = $this->getHttpVersion() . ' ' . $this->httpResponse . "\r\n";
100 100
 
101 101
         foreach ($this->getHeaders() as $name => $content) {
102
-            $stringResponse .= $name . ': '. $content . "\r\n";
102
+            $stringResponse .= $name . ': ' . $content . "\r\n";
103 103
         }
104 104
 
105 105
         // No content to concatenate
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
      * @return Response
125 125
      * @throws HttpException
126 126
      */
127
-    public static function create(string &$data) : Response
127
+    public static function create(string & $data) : Response
128 128
     {
129 129
         if (!\preg_match('/\\r\\n\\r\\n/', $data)) {
130 130
             throw new IncompleteHttpMessageException();
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
     {
163 163
         $httpElements = \explode(' ', $firstLine);
164 164
 
165
-        if (!\preg_match('/HTTP\/[1-2\.]+/',$httpElements[0])) {
165
+        if (!\preg_match('/HTTP\/[1-2\.]+/', $httpElements[0])) {
166 166
             throw Response::createNotHttpException($firstLine);
167 167
         }
168 168
         $response->setHttpVersion($httpElements[0]);
Please login to merge, or discard this patch.
src/Rfc6455/Handshake/ClientHandshake.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/Core/AbstractConnection.php 1 patch
Unused Use Statements   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -11,18 +11,18 @@
 block discarded – undo
11 11
 
12 12
 namespace Nekland\Woketo\Core;
13 13
 
14
-use Nekland\Woketo\Exception\NoHandlerException;
15
-use Nekland\Woketo\Exception\WebsocketException;
16
-use Nekland\Woketo\Message\MessageHandlerInterface;
17
-use Nekland\Woketo\Rfc6455\Frame;
18
-use Nekland\Woketo\Rfc6455\Handshake\HandshakeInterface;
19
-use Nekland\Woketo\Rfc6455\Message;
20
-use Nekland\Woketo\Rfc6455\MessageProcessor;
21
-use Nekland\Woketo\Utils\SimpleLogger;
22
-use Psr\Log\LoggerAwareTrait;
23
-use Psr\Log\LoggerInterface;
24
-use React\EventLoop\LoopInterface;
25
-use React\EventLoop\Timer\TimerInterface;
14
+use Nekland\Woketo\Exception\NoHandlerException;
15
+use Nekland\Woketo\Exception\WebsocketException;
16
+use Nekland\Woketo\Message\MessageHandlerInterface;
17
+use Nekland\Woketo\Rfc6455\Frame;
18
+use Nekland\Woketo\Rfc6455\Handshake\HandshakeInterface;
19
+use Nekland\Woketo\Rfc6455\Message;
20
+use Nekland\Woketo\Rfc6455\MessageProcessor;
21
+use Nekland\Woketo\Utils\SimpleLogger;
22
+use Psr\Log\LoggerAwareTrait;
23
+use Psr\Log\LoggerInterface;
24
+use React\EventLoop\LoopInterface;
25
+use React\EventLoop\Timer\TimerInterface;
26 26
 use React\Socket\Connection;
27 27
 
28 28
 abstract class AbstractConnection
Please login to merge, or discard this patch.
src/Server/WebSocketServer.php 1 patch
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,6 @@
 block discarded – undo
24 24
 use Nekland\Woketo\Rfc6455\MessageProcessor;
25 25
 use Nekland\Woketo\Utils\SimpleLogger;
26 26
 use Psr\Log\LoggerInterface;
27
-use Psr\Log\LogLevel;
28 27
 use React\EventLoop\LoopInterface;
29 28
 use React\Socket\ConnectionInterface;
30 29
 use React\Socket\ServerInterface;
Please login to merge, or discard this patch.
src/Utils/BitManipulation.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
             }
Please login to merge, or discard this patch.