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

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