Code Duplication    Length = 9-10 lines in 2 locations

PHPDaemon/Clients/WebSocket/Connection.php 1 location

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

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

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