\Omega\Filesystem\Stream StreamWrapper

Stream wrapper class for the Gaufrette filesystems.

Summary

Methods
Properties
Constants
setFilesystemMap
getFilesystemMap
register
stream_open
stream_read
stream_write
stream_close
stream_flush
stream_seek
stream_tell
stream_eof
stream_stat
url_stat
unlink
stream_cast
No public properties found
No public constants found
createFilesystemMap
streamWrapperUnregister
streamWrapperRegister
createStream
createStreamMode
No protected properties found
No protected constants found
No private methods found
filesystemMap
stream
No private constants found

Properties

$filesystemMap

$filesystemMap : \Omega\Filesystem\FilesystemMap

Type

FilesystemMap — The map of filesystems used by the stream wrapper.

$stream

$stream : \Omega\Filesystem\Stream\StreamInterface

Type

StreamInterface — The current stream being manipulated by this wrapper.

Methods

setFilesystemMap()

setFilesystemMap(\Omega\Filesystem\FilesystemMap  $map) : void

Defines the filesystem map.

Parameters

\Omega\Filesystem\FilesystemMap $map

Returns

void —

getFilesystemMap()

getFilesystemMap() : \Omega\Filesystem\FilesystemMap

Returns the filesystem map.

Returns

\Omega\Filesystem\FilesystemMap —

$map

register()

register(string  $scheme = 'omega') : void

Registers the stream wrapper to handle the specified scheme.

Parameters

string $scheme

Default is gaufrette

Returns

void —

stream_open()

stream_open(string  $path, string  $mode) : bool

Opens a stream to the specified path with the given mode.

This method initializes a stream for the given path by creating it via createStream() and then opening it in the specified mode using createStreamMode(). The mode determines the type of access (e.g., read, write) that will be performed on the stream.

Parameters

string $path

The full path to the resource to be opened.

string $mode

The mode for opening the stream (e.g., 'r', 'w', 'a').

Returns

bool —

Returns true if the stream was successfully opened, or false on failure.

stream_read()

stream_read(int  $bytes) : string|false

Parameters

int $bytes

Returns

string|false —

stream_write()

stream_write(string  $data) : int

Parameters

string $data

Returns

int —

stream_close()

stream_close() : void

Returns

void —

stream_flush()

stream_flush() : bool

Returns

bool —

stream_seek()

stream_seek(int  $offset, int  $whence = SEEK_SET) : bool

Parameters

int $offset
int $whence
  • one of values [SEEK_SET, SEEK_CUR, SEEK_END]

Returns

bool —

stream_tell()

stream_tell() : int

Returns

int —

stream_eof()

stream_eof() : bool

Returns

bool —

stream_stat()

stream_stat() : array|false

Returns

array|false —

url_stat()

url_stat(string  $path, int  $flags) : array|false

Parameters

string $path
int $flags

Returns

array|false —

unlink()

unlink(string  $path) : bool

Parameters

string $path

Returns

bool —

stream_cast()

stream_cast(int  $castAs) : mixed

Parameters

int $castAs

Returns

mixed —

createFilesystemMap()

createFilesystemMap() : \Omega\Filesystem\FilesystemMap

Returns

\Omega\Filesystem\FilesystemMap —

streamWrapperUnregister()

streamWrapperUnregister(string  $scheme) : bool

Parameters

string $scheme
  • protocol scheme

Returns

bool —

streamWrapperRegister()

streamWrapperRegister(string  $scheme, string  $className) : bool

Parameters

string $scheme
  • protocol scheme
string $className

Returns

bool —

createStream()

createStream(string  $path) : \Omega\Filesystem\Stream\StreamInterface

Creates a stream based on the provided path.

Parses the provided path into components and uses the scheme, host, and path to retrieve the corresponding filesystem from the filesystem map. It then creates and returns a stream for the specified file.

Parameters

string $path

The full path to the resource, including scheme and host.

Throws

\InvalidArgumentException

If the path is invalid or incomplete.

Returns

\Omega\Filesystem\Stream\StreamInterface —

Returns a stream object associated with the given path.

createStreamMode()

createStreamMode(string  $mode) : \Omega\Filesystem\Stream\StreamMode

Creates a StreamMode object based on the provided mode string.

The mode string is typically one of the standard PHP file modes (e.g., 'r', 'w', 'a'). This method wraps the mode in a StreamMode object that is used to interact with the underlying stream.

Parameters

string $mode

The mode for opening the stream (e.g., 'r', 'w', 'a').

Returns

\Omega\Filesystem\Stream\StreamMode —

Returns a StreamMode object that encapsulates the given mode.