Code Duplication    Length = 6-6 lines in 2 locations

src/Stream/AttachWebsocketStream.php 2 locations

@@ 43-48 (lines=6) @@
40
            'data'     => $data,
41
        ];
42
43
        if ($frame['mask'] == 1) {
44
            for ($i = 0; $i < $frame['len']; $i++) {
45
                $frame['data']{$i}
46
                    = chr(ord($frame['data']{$i}) ^ ord($frame['mask_key']{$i % 4}));
47
            }
48
        }
49
50
        if ($frame['len'] > pow(2, 16)) {
51
            $len = 127;
@@ 135-140 (lines=6) @@
132
        $frame['data'] = $this->socketRead($frame['len']);
133
134
        // Decode data if needed
135
        if ($frame['mask'] == 1) {
136
            for ($i = 0; $i < $frame['len']; $i++) {
137
                $frame['data']{$i} = chr(ord($frame['data']{$i}) ^ ord($frame['mask_key']{$i % 4}));
138
            }
139
        }
140
141
        if ($getFrame) {
142
            return $frame;
143
        }