Folder::from()

Object instantiator.

Table of Contents
  1. Description
  2. Example

Description

Folder::from(...$lot): self;

It is just a shortcut for the Folder::__construct() way.

Example

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

The example above is the same as the instantiation below:

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

Its purpose is to help you avoid using parentheses when you want to call a method directly from the class instance to minimize variable usage:

// Syntax error, unexpected token “->”, expecting “)”
$name = new Folder('.\path\to\folder')->name();

// :(
$folder = new Folder('.\path\to\folder');
$name = $folder->name();

$name = (new Folder('.\path\to\folder'))->name(); // :\
$name = Folder::from('.\path\to\folder')->name(); // :)

Folder::from()

Object instantiator.

Folder::size()

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