\Omega\Filesystem FilesystemMap

Class FilesystemMap.

The FilesystemMap class implements the FilesystemMapInterface and serves as a registry for associating filesystem instances with their respective names. It provides methods to register, retrieve, check the existence of, and remove filesystems by name, enabling a structured and manageable way to handle multiple filesystem implementations. This class ensures that the names of the filesystems follow a specific format, preventing the use of invalid characters.

It is particularly useful in scenarios where multiple filesystems are utilized, such as local storage, cloud storage, or remote filesystems, allowing easy access and management of these resources through a common interface.

Summary

Methods
Properties
Constants
all
set
has
get
remove
clear
No public properties found
No public constants found
No protected methods found
No protected properties found
No protected constants found
No private methods found
filesystems
No private constants found

Properties

$filesystems

$filesystems : array

An associative array that stores the registered filesystems.

Type

array<string|int, mixed> — Holds an associarive array that stores registered filesystem, where the key is the name of the filesystem and the value is the instance of the filesystem.

Methods

all()

all() : array

Get all the registered filesystems.

Each entry in the array has the filesystem name as the key and the corresponding filesystem instance as the value.

Returns

array —

Return an array of registered filesystem.

set()

set(string  $name, \Omega\Filesystem\FilesystemInterface  $filesystem) : void

Registers the given filesystem for the specified name.

This method associates a filesystem instance with a name in the registry. The name must contain only valid characters (letters, numbers, hyphens, and underscores) to ensure proper identification of the filesystem.

Parameters

string $name

The name to associate with the filesystem.

\Omega\Filesystem\FilesystemInterface $filesystem

The filesystem instance to register.

Throws

\InvalidArgumentException

When the specified name contains forbidden characters.

Returns

void —

has()

has(string  $name) : bool

Indicates whether there is a filesystem registered for the specified name.

Parameters

string $name

The name of the filesystem to check.

Returns

bool —

TRUE if a filesystem is registered for the specified name, FALSE otherwise.

get()

get(string  $name) : \Omega\Filesystem\FilesystemInterface

Returns the filesystem registered for the specified name.

Retrieves the filesystem registered under the specified name.

Parameters

string $name

The name of the filesystem to retrieve.

Throws

\InvalidArgumentException

When there is no filesystem defined for the specified name.

Returns

\Omega\Filesystem\FilesystemInterface —

The filesystem instance associated with the given name.

remove()

remove(string  $name) : void

Removes the filesystem registered for the specified name.

This method allows for the removal of a filesystem from the registry by its name. It throws an exception if the filesystem is not found in the registry.

Parameters

string $name

The name of the filesystem to remove.

Throws

\InvalidArgumentException

When the specified filesystem is not defined.

Returns

void —

clear()

clear() : void

Clears all the registered filesystems.

This method removes all entries from the filesystem registry, effectively resetting it to an empty state.

Returns

void —