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

@@ 195-206 (lines=12) @@
192
    /**
193
     * {@inheritdoc}
194
     */
195
    public function read($length, $blocking = true)
196
    {
197
        if (!$this->peek($length, $blocking)) {
198
            return null;
199
        }
200
201
        $data = substr($this->buffer, 0, $length);
202
203
        $this->buffer = substr($this->buffer, $length, strlen($this->buffer) - $length);
204
205
        return $data;
206
    }
207
208
    /**
209
     * @param int  $length