Folder::offsetGet()

Gets the file content by its relative path to the folder.

Table of Contents
  1. Description
  2. Example

Description

Folder::offsetGet(mixed $key): ?string;

This method is a requirement to be able to implement the ArrayAccess interface and aims to make the object data accessible using array access syntax. You won’t use this method directly, it will be executed automatically when you try to get a file/folder from the folder with array access syntax. This method gets a file/folder using its relative path to the folder. If the path does not exist in the folder, this method returns null.

Example

$folder = new Folder('.\path\to\folder');

test($folder['asdf.txt']); // Returns `null` because file `.\path\to\folder\asdf.txt` does not exist
test($folder['file.txt']); // Returns a `File` instance of `.\path\to\folder\file.txt`
test($folder['folder/123']); // Returns a `Folder` instance of `.\path\to\folder\folder\123`

Folder::offsetGet()

Gets the file content by its relative path to the folder.

Folder::size()

Gets the total sizes of files contained in the folder in human readable string format.