PHP Class Protobuf\Stream

Author: Fabio B. Silva ([email protected])
Show file Open project: protobuf-php/protobuf Class Usage Examples

Public Methods

Method Description
__construct ( resource $stream, integer $size = null )
__destruct ( ) Closes the stream when the destructed
__toString ( )
create ( ) : Stream Create a new stream.
eof ( ) : boolean Returns true if the stream is at the end of the stream.
fromString ( string $resource = '', integer $size = null ) : Stream Create a new stream from a string.
getContents ( ) : string Returns the remaining contents of the stream as a string.
getSize ( ) : integer | null Get the size of the stream
read ( integer $length ) : string Read data from the stream
readStream ( integer $length ) : Stream Read stream
seek ( integer $offset, integer $whence = SEEK_SET ) Seek to a position in the stream
tell ( ) : integer Returns the current position of the file read/write pointer
wrap ( Stream | resource | string $resource = '', integer $size = null ) : Stream Wrap the input resource in a stream object.
write ( string $bytes, integer $length ) : integer Write data to the stream
writeStream ( Stream $stream, integer $length ) : integer Write stream

Method Details

__construct() public method

public __construct ( resource $stream, integer $size = null )
$stream resource
$size integer

__destruct() public method

Closes the stream when the destructed
public __destruct ( )

__toString() public method

public __toString ( )

create() public static method

Create a new stream.
public static create ( ) : Stream
return Stream

eof() public method

Returns true if the stream is at the end of the stream.
public eof ( ) : boolean
return boolean

fromString() public static method

Create a new stream from a string.
public static fromString ( string $resource = '', integer $size = null ) : Stream
$resource string
$size integer
return Stream

getContents() public method

Returns the remaining contents of the stream as a string.
public getContents ( ) : string
return string

getSize() public method

Get the size of the stream
public getSize ( ) : integer | null
return integer | null Returns the size in bytes if known

read() public method

Read data from the stream
public read ( integer $length ) : string
$length integer
return string

readStream() public method

Read stream
public readStream ( integer $length ) : Stream
$length integer
return Stream

seek() public method

Seek to a position in the stream
public seek ( integer $offset, integer $whence = SEEK_SET )
$offset integer
$whence integer

tell() public method

Returns the current position of the file read/write pointer
public tell ( ) : integer
return integer

wrap() public static method

Wrap the input resource in a stream object.
public static wrap ( Stream | resource | string $resource = '', integer $size = null ) : Stream
$resource Stream | resource | string
$size integer
return Stream

write() public method

Write data to the stream
public write ( string $bytes, integer $length ) : integer
$bytes string
$length integer
return integer

writeStream() public method

Write stream
public writeStream ( Stream $stream, integer $length ) : integer
$stream Stream
$length integer
return integer