class Load

Class Load

Constants

UNABLE_TO_LOAD

Message for throw exception.

Properties

static protected array $dirs Array of directories.
static protected int $registered Total number of registered classes.
static private Load $instance Hold the classes on instance.
static private $fileExists Contains if loaded file exists.
static private array $fileLoaded

Methods

__construct(array|string $dirs = [])

Load constructor.

static 
init(array|string $dirs = [])

Adds a directory to the list of supported directories.

static 
addDirs(array|string $dirs)

Add more directories to our list of directories to test.

static Load
getInstance()

Return this instance.

static bool
autoLoad(string $class)

Performs the logic to locate the file based on the namespaced classname. This method derives a filename by converting the PHP namespace separator \ into the directory separator appropriate for this server and appending the extension .php.

static bool
loadFile(string $file)

Load a file if exists.

Details

at line 61
__construct(array|string $dirs = [])

Load constructor.

Parameters

array|string $dirs

at line 79
static init(array|string $dirs = [])

Adds a directory to the list of supported directories.

Also registers "autoload" as an autoloading method as a Standard PHP Library (SPL) autoloader.

Parameters

array|string $dirs

at line 103
static addDirs(array|string $dirs)

Add more directories to our list of directories to test.

Parameters

array|string $dirs

at line 116
static Load getInstance()

Return this instance.

Return Value

Load

at line 131
static bool autoLoad(string $class)

Performs the logic to locate the file based on the namespaced classname. This method derives a filename by converting the PHP namespace separator \ into the directory separator appropriate for this server and appending the extension .php.

Parameters

string $class

Return Value

bool

Exceptions

RuntimeException

at line 165
static protected bool loadFile(string $file)

Load a file if exists.

Returns true if file exists and is loaded, otherwise return false.

The reason for this method is that if the file is not founded, we don't generate a fatal error when requiring it.

Parameters

string $file Path to the file or directory.

Return Value

bool