Code Duplication    Length = 11-12 lines in 2 locations

src/IO/BufferIO.php 1 location

@@ 46-56 (lines=11) @@
43
    /**
44
     * {@inheritdoc}
45
     */
46
    public function read($length, $blocking = true)
47
    {
48
        if (strlen($this->readBuffer) >= $length) {
49
            $data = substr($this->readBuffer, 0, $length);
50
            $this->readBuffer = substr($this->readBuffer, $length, strlen($this->readBuffer) - $length);
51
52
            return $data;
53
        }
54
55
        return null;
56
    }
57
58
    /**
59
     * {@inheritdoc}

src/IO/StreamIO.php 1 location

@@ 221-232 (lines=12) @@
218
    /**
219
     * {@inheritdoc}
220
     */
221
    public function read($length, $blocking = true)
222
    {
223
        if (!$this->peek($length, $blocking)) {
224
            return null;
225
        }
226
227
        $data = substr($this->buffer, 0, $length);
228
229
        $this->buffer = substr($this->buffer, $length, strlen($this->buffer) - $length);
230
231
        return $data;
232
    }
233
234
    /**
235
     * @param int  $length