Completed
Push — master ( 7ffb1b...5b521f )
by y
01:19
created
src/WebSocket/Handshake.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -45,21 +45,21 @@  discard block
 block discarded – undo
45 45
     /**
46 46
      * @param WebSocketClient $client
47 47
      */
48
-    public function __construct (WebSocketClient $client) {
48
+    public function __construct(WebSocketClient $client) {
49 49
         $this->client = $client;
50 50
     }
51 51
 
52 52
     /**
53 53
      * @return string[][]
54 54
      */
55
-    public function getHeaders () {
55
+    public function getHeaders() {
56 56
         return $this->headers;
57 57
     }
58 58
 
59 59
     /**
60 60
      * @return string
61 61
      */
62
-    public function getMethod (): string {
62
+    public function getMethod(): string {
63 63
         return $this->method;
64 64
     }
65 65
 
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
      * @throws WebSocketError
71 71
      * @throws Throwable
72 72
      */
73
-    public function onReadable (): bool {
73
+    public function onReadable(): bool {
74 74
         // read into the buffer
75 75
         $this->buffer .= $bytes = $this->client->recvAll();
76 76
 
@@ -128,8 +128,8 @@  discard block
 block discarded – undo
128 128
     /**
129 129
      * Sends the connection upgrade headers.
130 130
      */
131
-    protected function upgrade (): void {
132
-        $key = base64_encode(sha1(current($this->headers['sec-websocket-key']) . self::RFC_GUID, true));
131
+    protected function upgrade(): void {
132
+        $key = base64_encode(sha1(current($this->headers['sec-websocket-key']).self::RFC_GUID, true));
133 133
         $this->client->write(implode("\r\n", [
134 134
             "HTTP/1.1 101 Switching Protocols",
135 135
             "Connection: Upgrade",
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
      *
144 144
      * @throws WebSocketError
145 145
      */
146
-    protected function validate (): void {
146
+    protected function validate(): void {
147 147
         if (!(
148 148
             $check = 'method = http 1.1'
149 149
             and preg_match('/HTTP\/1\.1$/i', $this->method)
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -107,12 +107,10 @@
 block discarded – undo
107 107
             }
108 108
             $this->buffer = ''; // wipe the buffer
109 109
             $this->validate();
110
-        }
111
-        catch (WebSocketError $e) { // catch and respond with HTTP error and rethrow
110
+        } catch (WebSocketError $e) { // catch and respond with HTTP error and rethrow
112 111
             $this->client->write("HTTP/1.1 {$e->getCode()} WebSocket Handshake Failure\r\n\r\n");
113 112
             throw $e;
114
-        }
115
-        catch (Throwable $e) { // catch everything else and respond with HTTP 500 and rethrow
113
+        } catch (Throwable $e) { // catch everything else and respond with HTTP 500 and rethrow
116 114
             $this->client->write("HTTP/1.1 500 WebSocket Internal Error\r\n\r\n");
117 115
             throw $e;
118 116
         }
Please login to merge, or discard this patch.