Index Documentation

Stream
in package
implements Stringable, ICloseable

AbstractYes

Represents a generic data stream.

Table of Contents

Interfaces

Stringable
ICloseable
Provides an interface for releasing unmanaged resources.

Constants

CURRENT  = SEEK_CUR
Place the cursor relative to the current position of the cursor.
END  = SEEK_END
Place the cursor relative to the end of the file.
START  = SEEK_SET
Place the cursor relative to the start of the file.

Methods

__destruct()  : mixed
__toString()  : string
canRead()  : bool
Whether this stream is readable.
canSeek()  : bool
Whether this stream is seekable.
canWrite()  : bool
Whether this stream is writeable.
close()  : void
Free, release or reset unmanaged resources.
copyTo()  : void
Copy the entire contents of this stream to another.
flush()  : void
Force write of all buffered output to the stream.
getLength()  : int
Retrieves the current length of the stream.
getPosition()  : int
Retrieves the current cursor position.
hasTimedOut()  : bool
Whether this stream has timed out.
isBlocking()  : bool
Whether this stream has blocking operations.
isEnded()  : bool
Whether the cursor is at the end of the file.
read()  : string|null
Read an amount of data from the stream.
readByte()  : int
Read a single byte from the stream.
readChar()  : string|null
Read a single character from the stream.
readLine()  : string|null
Read a line of text from the stream.
seek()  : bool
Move the cursor to a different place in the stream.
setLength()  : void
Sets the length of the stream.
write()  : void
Write an amount of data to the stream.
writeByte()  : void
Writes a single byte to the stream.
writeChar()  : void
Writes a single character to the stream.
writeLine()  : void
Writes a line of text to the stream.

Constants

CURRENT

Place the cursor relative to the current position of the cursor.

public int CURRENT = SEEK_CUR

END

Place the cursor relative to the end of the file.

public int END = SEEK_END

START

Place the cursor relative to the start of the file.

public int START = SEEK_SET

Methods

__destruct()

public __destruct() : mixed

__toString()

public __toString() : string
Return values
string

canRead()

Whether this stream is readable.

public abstract canRead() : bool
Return values
bool

true if the stream is readable.

canSeek()

Whether this stream is seekable.

public abstract canSeek() : bool
Return values
bool

true if the stream is seekable.

canWrite()

Whether this stream is writeable.

public abstract canWrite() : bool
Return values
bool

true if the stream is writeable.

close()

Free, release or reset unmanaged resources.

public abstract close() : void

copyTo()

Copy the entire contents of this stream to another.

public copyTo(Stream $other) : void

Will seek to the beginning of the stream if the stream is seekable.

Parameters
$other : Stream

Target stream.

flush()

Force write of all buffered output to the stream.

public abstract flush() : void

getLength()

Retrieves the current length of the stream.

public abstract getLength() : int
Return values
int

Stream length.

getPosition()

Retrieves the current cursor position.

public abstract getPosition() : int
Return values
int

Cursor position.

hasTimedOut()

Whether this stream has timed out.

public abstract hasTimedOut() : bool
Return values
bool

true if the stream has timed out.

isBlocking()

Whether this stream has blocking operations.

public abstract isBlocking() : bool
Return values
bool

true if the stream has blocking operations.

isEnded()

Whether the cursor is at the end of the file.

public abstract isEnded() : bool
Return values
bool

true if the cursor is at the end of the file.

read()

Read an amount of data from the stream.

public abstract read(int $length) : string|null
Parameters
$length : int

Maximum amount of data to read.

Return values
string|null

At most a $length sized string or null if we're at the end of the stream.

readByte()

Read a single byte from the stream.

public readByte() : int
Return values
int

One byte or -1 if we're at the end of the stream.

readChar()

Read a single character from the stream.

public abstract readChar() : string|null
Return values
string|null

One character or null if we're at the end of the stream.

readLine()

Read a line of text from the stream.

public abstract readLine() : string|null
Return values
string|null

One line of text or null if we're at the end of the stream.

seek()

Move the cursor to a different place in the stream.

public abstract seek(int $offset[, int $origin = self::START ]) : bool
Parameters
$offset : int

Offset to apply to the cursor position.

$origin : int = self::START

Point from which to apply the offset.

Tags
throws
RuntimeException

If the stream is not seekable.

Return values
bool

true if the cursor offset was applied successfully.

setLength()

Sets the length of the stream.

public abstract setLength(int $length) : void
Parameters
$length : int

Desired stream length.

write()

Write an amount of data to the stream.

public abstract write(string $buffer[, int $length = -1 ]) : void
Parameters
$buffer : string

Buffer to write from.

$length : int = -1

Amount of data to write from the buffer, or -1 to write the entire buffer.

writeByte()

Writes a single byte to the stream.

public writeByte(int $byte) : void
Parameters
$byte : int

Byte to write to the stream.

writeChar()

Writes a single character to the stream.

public abstract writeChar(string $char) : void
Parameters
$char : string

Character to write to the stream.

writeLine()

Writes a line of text to the stream.

public writeLine(string $line) : void
Parameters
$line : string

Line of text to write.


        
On this page

Search results