$content
$content : mixed|null
The content of the file. It is lazy-loaded and will be retrieved from the filesystem on first request.
Class File.
This class represents a file within a filesystem. It provides methods to manage the file's content, metadata, and existence in the filesystem. The file content is lazily loaded, meaning it will not be retrieved from the filesystem until it is specifically requested. This optimizes performance by avoiding unnecessary file reads.
$filesystem : \Omega\Filesystem\FilesystemInterface
__construct(string $key, \Omega\Filesystem\FilesystemInterface $filesystem) : mixed
Constructor to initialize the File object.
string | $key | The key (path) of the file in the filesystem. |
\Omega\Filesystem\FilesystemInterface | $filesystem | The filesystem interface to interact with the filesystem. |
getContent(array $metadata = []) : string
Retrieve the content of the file. The content is loaded lazily on the first call.
array | $metadata | Optional metadata to be set when reading. |
If the file cannot be found in the filesystem.
The content of the file.
setContent(string $content, array $metadata = []) : int
Set the content of the file. This will also update the size and metadata.
string | $content | The content to be written to the file. |
array | $metadata | Optional metadata to be sent when writing. |
The number of bytes written to the file, or FALSE on failure.
delete(array $metadata = []) : bool
Delete the file from the filesystem.
array | $metadata | Optional metadata to be sent when deleting. |
If the file cannot be found.
If the file cannot be deleted.
TRUE on success, FALSE on failure.