Completed
Push — master ( be1d94...98b8cf )
by Valentin
13s
created
src/Client/Connection.php 2 patches
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\Socket\ConnectionInterface;
28 28
 
29 29
 class Connection extends AbstractConnection
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 (ConnectionInterface $stream) {
55
+        $clientPromise->then(function(ConnectionInterface $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(ConnectionInterface $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
 
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 
124 124
             if ($this->currentMessage->isComplete()) {
125 125
                 // Sending the message through the woketo API.
126
-                switch($this->currentMessage->getOpcode()) {
126
+                switch ($this->currentMessage->getOpcode()) {
127 127
                     case Frame::OP_TEXT:
128 128
                         $this->getHandler()->onMessage($this->currentMessage->getContent(), $this);
129 129
                         break;
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 
136 136
             } else {
137 137
                 // We wait for more data so we start a timeout.
138
-                $this->timeout = $this->loop->addTimer(Connection::DEFAULT_TIMEOUT, function () {
138
+                $this->timeout = $this->loop->addTimer(Connection::DEFAULT_TIMEOUT, function() {
139 139
                     $this->getLogger()->notice('Connection to ' . $this->getIp() . ' timed out.');
140 140
                     $this->messageProcessor->timeout($this->stream);
141 141
                 });
Please login to merge, or discard this patch.
src/Core/AbstractConnection.php 1 patch
Unused Use Statements   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -11,19 +11,19 @@
 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;
26
-use React\Socket\Connection;
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
+use React\Socket\Connection;
27 27
 use React\Socket\ConnectionInterface;
28 28
 
29 29
 abstract class AbstractConnection
Please login to merge, or discard this patch.
src/Server/WebSocketServer.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
         $this->buildMessageProcessor();
97 97
 
98 98
         // Some optimization
99
-        \gc_enable();       // As the process never stops, the garbage collector will be usefull, you may need to call it manually sometimes for performance purpose
99
+        \gc_enable(); // As the process never stops, the garbage collector will be usefull, you may need to call it manually sometimes for performance purpose
100 100
         \set_time_limit(0); // It's by default on most server for cli apps but better be sure of that fact
101 101
     }
102 102
 
@@ -106,13 +106,13 @@  discard block
 block discarded – undo
106 106
      */
107 107
     public function setMessageHandler($messageHandler, $uri = '*')
108 108
     {
109
-        if (!$messageHandler instanceof MessageHandlerInterface &&  !\is_string($messageHandler)) {
109
+        if (!$messageHandler instanceof MessageHandlerInterface && !\is_string($messageHandler)) {
110 110
             throw new \InvalidArgumentException('The message handler must be an instance of MessageHandlerInterface or a string.');
111 111
         }
112 112
         if (\is_string($messageHandler)) {
113 113
             try {
114 114
                 $reflection = new \ReflectionClass($messageHandler);
115
-                if(!$reflection->implementsInterface('Nekland\Woketo\Message\MessageHandlerInterface')) {
115
+                if (!$reflection->implementsInterface('Nekland\Woketo\Message\MessageHandlerInterface')) {
116 116
                     throw new \InvalidArgumentException('The messageHandler must implement MessageHandlerInterface');
117 117
                 }
118 118
             } catch (\ReflectionException $e) {
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
             $this->getLogger()->info('Enabled ssl');
145 145
         }
146 146
 
147
-        $this->server->on('connection', function ($socketStream) {
147
+        $this->server->on('connection', function($socketStream) {
148 148
             $this->onNewConnection($socketStream);
149 149
         });
150 150
 
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
      */
159 159
     private function onNewConnection(ConnectionInterface $socketStream)
160 160
     {
161
-        $connection = new Connection($socketStream, function ($uri, Connection $connection) {
161
+        $connection = new Connection($socketStream, function($uri, Connection $connection) {
162 162
             return $this->getMessageHandler($uri, $connection);
163 163
         }, $this->loop, $this->messageProcessor);
164 164
 
Please login to merge, or discard this patch.