Subversion Repositories oidplus

Rev

Rev 846 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
827 daniel-mar 1
<?php
2
 
3
/**
4
 * ReadBytes trait
5
 *
6
 * PHP version 5
7
 *
874 daniel-mar 8
 * @category  System
9
 * @package   SSH
827 daniel-mar 10
 * @author    Jim Wigginton <terrafrost@php.net>
11
 * @copyright 2015 Jim Wigginton
12
 * @license   http://www.opensource.org/licenses/mit-license.html  MIT License
13
 * @link      http://phpseclib.sourceforge.net
14
 */
15
 
16
namespace phpseclib3\System\SSH\Common\Traits;
17
 
18
/**
19
 * ReadBytes trait
20
 *
874 daniel-mar 21
 * @package SSH
827 daniel-mar 22
 * @author  Jim Wigginton <terrafrost@php.net>
874 daniel-mar 23
 * @access  public
827 daniel-mar 24
 */
25
trait ReadBytes
26
{
27
    /**
28
     * Read data
29
     *
30
     * @param int $length
31
     * @throws \RuntimeException on connection errors
874 daniel-mar 32
     * @access public
827 daniel-mar 33
     */
34
    public function readBytes($length)
35
    {
36
        $temp = fread($this->fsock, $length);
37
        if (strlen($temp) != $length) {
38
            throw new \RuntimeException("Expected $length bytes; got " . strlen($temp));
39
        }
40
        return $temp;
41
    }
42
}