Class

TRex\Loader\ClassLoader

class ClassLoader

ClassLoader loads the file of a php class.

PSR-0 autoloader.

Constants

FILE_EXTENSION

Extension of PHP file.

Methods

__construct(bool $isErrorDisplayed = false)

Constructor.

bool register(array $vendors = array())

Starts auto-loading of php classes.

bool unRegister()

Stops auto-loading of php classes.

mixed|null load(string $className)

Loads a php class.

string getClassPath(string $className)

Gets the path of the file containing the class $className.

bool hasVendor(string $vendorName)

Indicates whether a vendor has been already added.

bool addVendor(string $name, string $sourcePath)

Adds vendor data.

bool addVendors(array $vendors)

Add sa list of vendor data.

bool removeVendor(string $vendorName)

Removes a vendor.

string getSourcePath(string $vendorName)

Gets a vendor source path.

string getRootDir(string $vendorName)

Gets a vendor root dir.

string getRealPath(string $vendorName)

Gets a vendor real path.

string getBasePath()

Getter of the common root of all paths.

setBasePath(string $basePath)

Setter of the common root of all paths.

boolean isErrorDisplayed()

Indicates whether self::load displays an exception.

setErrorDisplayed(boolean $isErrorDisplayed)

Sets the display of exception for self::load.

Details

at line 58
public __construct(bool $isErrorDisplayed = false)

Constructor.

Parameters

bool $isErrorDisplayed

at line 70
public bool register(array $vendors = array())

Starts auto-loading of php classes.

Call automatically self::load when a new class is used.

Parameters

array $vendors

Return Value

bool

at line 81
public bool unRegister()

Stops auto-loading of php classes.

Return Value

bool

at line 95
public mixed|null load(string $className)

Loads a php class.

If no class is founded, a exception is thrown. Return the result of the included file of null if no file included.

Parameters

string $className

Return Value

mixed|null

Exceptions

Exception

at line 117
public string getClassPath(string $className)

Gets the path of the file containing the class $className.

If the class has a no vendor or a vendor not recoded, a empty string will be returned.

Parameters

string $className

Return Value

string

at line 133
public bool hasVendor(string $vendorName)

Indicates whether a vendor has been already added.

Parameters

string $vendorName

Return Value

bool

at line 145
public bool addVendor(string $name, string $sourcePath)

Adds vendor data.

Parameters

string $name
string $sourcePath

Return Value

bool

at line 164
public bool addVendors(array $vendors)

Add sa list of vendor data.

Keys are names and values are source path; See self::addVendor().

Parameters

array $vendors

Return Value

bool

at line 179
public bool removeVendor(string $vendorName)

Removes a vendor.

Parameters

string $vendorName

Return Value

bool

at line 194
public string getSourcePath(string $vendorName)

Gets a vendor source path.

Parameters

string $vendorName

Return Value

string

at line 209
public string getRootDir(string $vendorName)

Gets a vendor root dir.

The root dir is the absolute path to the first directory of the source path.

Parameters

string $vendorName

Return Value

string

at line 221
public string getRealPath(string $vendorName)

Gets a vendor real path.

The real path is the absolute path to the source.

Parameters

string $vendorName

Return Value

string

at line 231
public string getBasePath()

Getter of the common root of all paths.

Return Value

string

at line 241
public setBasePath(string $basePath)

Setter of the common root of all paths.

Parameters

string $basePath

at line 251
public boolean isErrorDisplayed()

Indicates whether self::load displays an exception.

Return Value

boolean

at line 261
public setErrorDisplayed(boolean $isErrorDisplayed)

Sets the display of exception for self::load.

Parameters

boolean $isErrorDisplayed