Code Duplication    Length = 12-14 lines in 2 locations

PHPDaemon/FS/File.php 2 locations

@@ 582-595 (lines=14) @@
579
     * @param  string &$buf
580
     * @return callable
581
     */
582
    protected function readAllGenHandler($cb, $size, &$offset, &$pri, &$buf)
583
    {
584
        return function ($file, $data) use ($cb, $size, &$offset, &$pri, &$buf) {
585
            $buf .= $data;
586
            $offset += mb_orig_strlen($data);
587
            $len = min($file->chunkSize, $size - $offset);
588
            if ($offset >= $size) {
589
                if ($cb) {
590
                    $cb($file, $buf);
591
                }
592
                return;
593
            }
594
            eio_read($file->fd, $len, $offset, $pri, $this->readAllGenHandler($cb, $size, $offset, $pri, $buf), $this);
595
        };
596
    }
597
598
    /**
@@ 650-661 (lines=12) @@
647
     * @param  integer $pri
648
     * @return callable
649
     */
650
    protected function readAllChunkedGenHandler($cb, $chunkcb, $size, &$offset, $pri)
651
    {
652
        return function ($file, $data) use ($cb, $chunkcb, $size, &$offset, $pri) {
653
            $chunkcb($file, $data);
654
            $offset += mb_orig_strlen($data);
655
            $len = min($file->chunkSize, $size - $offset);
656
657
            if ($offset >= $size) {
658
                $cb($file, true);
659
                return;
660
            }
661
662
            eio_read(
663
                $file->fd,
664
                $len,