pssht  latest
SSH server library written in PHP
fpoirotte\Pssht\Buffer Class Reference
+ Inheritance diagram for fpoirotte\Pssht\Buffer:

Public Member Functions

 __construct ($data= '')
 
 count ()
 
 get ($limit)
 
 push ($data)
 
 unget ($data)
 

Protected Member Functions

 getDelimiter ($limit)
 
 getLength ($limit)
 

Protected Attributes

 $data
 The buffer's current data.
 

Detailed Description

Generic buffer.

Definition at line 17 of file Buffer.php.

Constructor & Destructor Documentation

fpoirotte\Pssht\Buffer::__construct (   $data = '')

Construct a new buffer.

Parameters
string$data(optional) Initial data for the buffer. If omitted, the buffer is initialized empty.

Definition at line 29 of file Buffer.php.

References fpoirotte\Pssht\Buffer\$data.

Member Function Documentation

fpoirotte\Pssht\Buffer::count ( )

Return the size (in bytes) of the data currently stored in the buffer.

Return values
intThe size of the buffer's current data.

Implements Countable.

Definition at line 45 of file Buffer.php.

fpoirotte\Pssht\Buffer::get (   $limit)

Get limited data from the beginning of the buffer.

Parameters
int | string$limitEither the number of bytes to retrieve from the buffer, or a string delimiter to look for.
Return values
stringThe data at the beginning of the buffer, until the given limit is reached. For string delimiters, the delimiter is part of the result.

Definition at line 123 of file Buffer.php.

References fpoirotte\Pssht\Buffer\getDelimiter(), and fpoirotte\Pssht\Buffer\getLength().

fpoirotte\Pssht\Buffer::getDelimiter (   $limit)
protected

Return a delimited string from the buffer.

Parameters
string$limitDelimiter.
Return values
stringAll the data at the beginning of the buffer up to (and including) the delimiter.
nullThe given delimiter does not appear in the buffer.

Definition at line 93 of file Buffer.php.

Referenced by fpoirotte\Pssht\Buffer\get().

fpoirotte\Pssht\Buffer::getLength (   $limit)
protected

Return a limited amount of data from the buffer.

Parameters
int$limitNumber of bytes to retrieve from the buffer.
Return values
stringExactly $limit bytes of data from the buffer.
nullThe buffer contains less than $limit bytes of data.

Definition at line 63 of file Buffer.php.

Referenced by fpoirotte\Pssht\Buffer\get().

fpoirotte\Pssht\Buffer::push (   $data)

Append data to the end of the buffer.

Parameters
string$dataData to append.
Return values
BufferReturns this buffer.

Definition at line 164 of file Buffer.php.

References fpoirotte\Pssht\Buffer\$data.

fpoirotte\Pssht\Buffer::unget (   $data)

Prepend data to the beginning of the buffer.

Parameters
string$dataData to prepend.
Return values
BufferReturns this buffer.

Definition at line 145 of file Buffer.php.

References fpoirotte\Pssht\Buffer\$data.


The documentation for this class was generated from the following file: