Code Duplication    Length = 9-10 lines in 4 locations

PHPDaemon/Network/IOStream.php 4 locations

@@ 957-966 (lines=10) @@
954
     * Reads all data from the connection's buffer
955
     * @return string Readed data
956
     */
957
    public function readUnlimited()
958
    {
959
        if (!isset($this->bev)) {
960
            return false;
961
        }
962
        $read = $this->bev->read($this->bev->input->length);
963
        if ($read === null) {
964
            return false;
965
        }
966
        return $read;
967
    }
968
}
969
@@ 481-489 (lines=9) @@
478
     * @param  integer $o Offset
479
     * @return string|false
480
     */
481
    public function lookExact($n, $o = 0)
482
    {
483
        if (!isset($this->bev)) {
484
            return false;
485
        }
486
        if ($o + $n > $this->bev->input->length) {
487
            return false;
488
        }
489
        return $this->bev->input->substr($o, $n);
490
    }
491
492
    /**
@@ 524-532 (lines=9) @@
521
     * @param integer $o Offset
522
     * @return string|false
523
     */
524
    public function look($n, $o = 0)
525
    {
526
        if (!isset($this->bev)) {
527
            return false;
528
        }
529
        if ($this->bev->input->length <= $o) {
530
            return '';
531
        }
532
        return $this->bev->input->substr($o, $n);
533
    }
534
535
    /**
@@ 566-575 (lines=10) @@
563
     * @param  integer $n Number of bytes to read
564
     * @return string|false
565
     */
566
    public function readExact($n)
567
    {
568
        if ($n === 0) {
569
            return '';
570
        }
571
        if (!$this->bev || $this->bev->input->length < $n) {
572
            return false;
573
        }
574
        return $this->read($n);
575
    }
576
577
    /**
578
     * Returns length of input buffer