Code Duplication    Length = 9-10 lines in 2 locations

PHPDaemon/Clients/WebSocket/Connection.php 1 location

@@ 231-239 (lines=9) @@
228
                chr($payloadLength & 0xFF);
229
        }
230
        $this->write($hdrPacket);
231
        if ($isMasked) {
232
            $this->write($mask = chr(mt_rand(0, 0xFF)) .
233
                chr(mt_rand(0, 0xFF)) .
234
                chr(mt_rand(0, 0xFF)) .
235
                chr(mt_rand(0, 0xFF)));
236
            $this->write(static::mask($mask, $payload));
237
        } else {
238
            $this->write($payload);
239
        }
240
    }
241
242
    /**

PHPDaemon/Servers/WebSocket/Protocols/V13.php 1 location

@@ 147-156 (lines=10) @@
144
                chr($dataLength >> 8) .
145
                chr($dataLength & 0xFF));
146
        }
147
        if ($isMasked) {
148
            $mask = chr(mt_rand(0, 0xFF)) .
149
                chr(mt_rand(0, 0xFF)) .
150
                chr(mt_rand(0, 0xFF)) .
151
                chr(mt_rand(0, 0xFF));
152
            $this->write($mask . $this->mask($data, $mask));
153
        } else {
154
            $this->write($data);
155
        }
156
        if ($cb !== null) {
157
            $this->onWriteOnce($cb);
158
        }
159
        return true;