\rex_factory_trait

Factory trait.

Example child class: class rex_example { use rex_factory;

private function __construct($param)
{
    // ...
}

public static function factory($param)
{
    $class = self::getFactoryClass();
    return new $class($param);
}

}

Summary

Methods
Properties
Constants
setFactoryClass()
getFactoryClass()
hasFactoryClass()
No public properties found
No constants found
callFactoryClass()
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

setFactoryClass()

setFactoryClass(string  $subclass) : mixed

Sets the class for the factory.

Parameters

string $subclass

Classname

Throws

\InvalidArgumentException

Returns

mixed —

getFactoryClass()

getFactoryClass() : string

Returns the class for the factory.

Returns

string —

hasFactoryClass()

hasFactoryClass() : bool

Returns if the class has a custom factory class.

Returns

bool —

callFactoryClass()

callFactoryClass(string  $method, array  $arguments) : mixed

Calls the factory class with the given method and arguments.

Parameters

string $method

Method name

array $arguments

Array of arguments

Returns

mixed —

Result of the callback