Moodle PHP Documentation 4.3
Moodle 4.3.5 (Build: 20240610) (7dcfaa79f78)
Stream

Functions

 __clone ()
 
 __construct (array $opts=array())
 Constructor.
 
 __get ($name)
 
 __serialize ()
 
 __set ($name, $value)
 
 __toString ()
 String representation of object.
 
 __unserialize ($data)
 
 _init ()
 Initialization method.
 
 add ($data, $reset=false)
 Adds data to the stream.
 
 close ()
 Close the stream.
 
 end ($offset=0)
 Move internal pointer to the end of the stream.
 
 eof ()
 Has the end of the stream been reached?
 
 getChar ()
 Return a character from the string.
 
 getEOL ()
 Auto-determine the EOL string.
 
 getString ($start=null, $end=null)
 Returns the stream (or a portion of it) as a string.
 
 getToChar ($end, $all=true)
 Get a string up to a certain character (or EOF).
 
 length ($utf8=false)
 Returns the length of the data.
 
 peek ($length=1)
 Return the current character(s) without moving the pointer.
 
 pos ()
 Return the current stream pointer position.
 
 rewind ()
 Rewind the internal stream to the beginning.
 
 search ($char, $reverse=false, $reset=true)
 Search for character(s) and return its position.
 
 seek ($offset=0, $curr=true, $char=false)
 Move internal pointer.
 
 serialize ()
 
 substring ($start=0, $length=null, $char=false)
 Return part of the stream as a string.
 
 unserialize ($data)
 

Variables

array $_params
 Configuration parameters.
 
boolean $_utf8_char = false
 Parse character as UTF-8 data instead of single byte.
 
*See the enclosed file LICENSE for license information(LGPL). If you *did not receive this file see http
 
*See the enclosed file LICENSE for license information(LGPL). If you *did not receive this file see http
 
*See the enclosed file LICENSE for license information(LGPL). If you *did not receive this file see http
 
*See the enclosed file LICENSE for license information(LGPL). If you *did not receive this file see http
 
*See the enclosed file LICENSE for license information(LGPL). If you *did not receive this file see http
 
$this stream = $opts['stream']
 
$this stream = Horde_Stream_Wrapper_String::getStream($opts['string'])
 

Detailed Description

Function Documentation

◆ __construct()

__construct ( array $opts = array())

Constructor.

Parameters
array$optsConfiguration options.

◆ __serialize()

__serialize ( )
Return values
array

◆ __toString()

__toString ( )

String representation of object.

Since
1.1.0
Return values
stringThe full stream converted to a string.

◆ __unserialize()

__unserialize ( $data)
Parameters
array$data
Return values
void

◆ _init()

_init ( )
protected

Initialization method.

Exceptions
Horde_Stream_Exception

◆ add()

add ( $data,
$reset = false )

Adds data to the stream.

Parameters
mixed$dataData to add to the stream. Can be a resource, Horde_Stream object, or a string(-ish) value.
boolean$resetReset stream pointer to initial position after adding?

◆ close()

close ( )

Close the stream.

Since
1.4.0

◆ end()

end ( $offset = 0)

Move internal pointer to the end of the stream.

Since
1.4.0
Parameters
integer$offsetMove this offset from the end.
Return values
booleanTrue if successful.

◆ eof()

eof ( )

Has the end of the stream been reached?

Since
1.4.0
Return values
booleanTrue if the end of the stream has been reached.

◆ getChar()

getChar ( )

Return a character from the string.

Since
1.4.0
Return values
stringCharacter (single byte, or UTF-8 character if $utf8_char is true).

◆ getEOL()

getEOL ( )

Auto-determine the EOL string.

Since
1.3.0
Return values
stringThe EOL string, or null if no EOL found.

◆ getString()

getString ( $start = null,
$end = null )

Returns the stream (or a portion of it) as a string.

Position values are the byte position in the stream.

Parameters
integer$startThe starting position. If positive, start from this position. If negative, starts this length back from the current position. If null, starts from the current position.
integer$endThe ending position relative to the beginning of the stream (if positive). If negative, end this length back from the end of the stream. If null, reads to the end of the stream.
Return values
stringA string.

◆ getToChar()

getToChar ( $end,
$all = true )

Get a string up to a certain character (or EOF).

Parameters
string$endThe character to stop reading at. As of 1.4.0, $char can be a multi-character UTF-8 string.
boolean$allIf true, strips all repetitions of $end from the end. If false, stops at the first instance of $end. (
Since
1.5.0)
Return values
stringThe string up to $end (stream is positioned after the end character(s), all of which are stripped from the return data).

◆ length()

length ( $utf8 = false)

Returns the length of the data.

Does not change the stream position.

Parameters
boolean$utf8If true, determines the UTF-8 length of the stream (as of 1.4.0). If false, determines the byte length of the stream.
Return values
integerStream size.
Exceptions
Horde_Stream_Exception

◆ peek()

peek ( $length = 1)

Return the current character(s) without moving the pointer.

Parameters
integer$lengthThe peek length (since 1.4.0).
Return values
stringThe current character.

◆ pos()

pos ( )

Return the current stream pointer position.

Since
1.4.0
Return values
mixedThe current position (integer), or false.

◆ rewind()

rewind ( )

Rewind the internal stream to the beginning.

Since
1.4.0
Return values
booleanTrue if successful.

◆ search()

search ( $char,
$reverse = false,
$reset = true )

Search for character(s) and return its position.

Parameters
string$charThe character to search for. As of 1.4.0, $char can be a multi-character UTF-8 string.
boolean$reverseDo a reverse search?
boolean$resetReset the pointer to the original position?
Return values
mixedThe start position of the search string (integer), or null if character not found.

◆ seek()

seek ( $offset = 0,
$curr = true,
$char = false )

Move internal pointer.

Since
1.4.0
Parameters
integer$offsetThe offset.
boolean$currIf true, offset is from current position. If false, offset is from beginning of stream.
boolean$charIf true, $offset is the length in characters. If false, $offset is the length in bytes.
Return values
booleanTrue if successful.

◆ substring()

substring ( $start = 0,
$length = null,
$char = false )

Return part of the stream as a string.

Since
1.4.0
Parameters
integer$startStart, as an offset from the current postion.
integer$lengthLength of string to return. If null, returns rest of the stream. If negative, this many characters will be omitted from the end of the stream.
boolean$charIf true, $start/$length is the length in characters. If false, $start/$length is the length in bytes.
Return values
stringThe substring.