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

@@ 188-199 (lines=12) @@
185
    /**
186
     * {@inheritdoc}
187
     */
188
    public function read($length, $blocking = true)
189
    {
190
        if ($this->peek($length, $blocking) === null) {
191
            return null;
192
        }
193
194
        $data = substr($this->buffer, 0, $length);
195
196
        $this->buffer = substr($this->buffer, $length, strlen($this->buffer) - $length);
197
198
        return $data;
199
    }
200
201
    /**
202
     * @param int  $length