Class

TRex\Core\Object

abstract class Object implements IObject

Base object.

Can be dynamic. Can be converted.

Methods

__construct(mixed $data = null)

Constructor.

mixed __get(string $propertyName)

See PHP doc.

mixed __set(string $propertyName, mixed $value)

See PHP doc.

mixed __call(string $methodName, array $args)

See PHP doc.

boolean isDynamic()

Indicates whether the current object has dynamic properties access.

setDynamic(boolean $isDynamic)

Sets dynamic properties access.

addMethod(string $name, Closure $method)

Adds a dynamic method to the object.

array toArray()

Converts an object to an array.

Json toJson(int $options = JSON_PRETTY_PRINT)

Converts an object to a Json object.

string __toString()

See PHP doc.

Details

at line 42
public __construct(mixed $data = null)

Constructor.

$data is initial data to set in the object. Keys are property names, and values are initial property values. $data could be a JSON string, an array or an array castable object.

Parameters

mixed $data

at line 58
public mixed __get(string $propertyName)

See PHP doc.

Parameters

string $propertyName

Return Value

mixed

Exceptions

RuntimeException

at line 78
public mixed __set(string $propertyName, mixed $value)

See PHP doc.

Parameters

string $propertyName
mixed $value

Return Value

mixed

Exceptions

RuntimeException

at line 101
public mixed __call(string $methodName, array $args)

See PHP doc.

Call dynamically a method added with self::addMethod(). After having added a method, it is possible to call it like a declared method $object->newMethod($arg)

Parameters

string $methodName
array $args

Return Value

mixed

Exceptions

RuntimeException

at line 116
public boolean isDynamic()

Indicates whether the current object has dynamic properties access.

Return Value

boolean

at line 126
public setDynamic(boolean $isDynamic)

Sets dynamic properties access.

Parameters

boolean $isDynamic

at line 137
public addMethod(string $name, Closure $method)

Adds a dynamic method to the object.

Parameters

string $name
Closure $method

at line 147
public array toArray()

Converts an object to an array.

The exported array contains all property values of the class and its parents, which are not transient.

Return Value

array

at line 157
public Json toJson(int $options = JSON_PRETTY_PRINT)

Converts an object to a Json object.

The exported data contains all property values ofn the class and its parents, who are not transient.

Parameters

int $options

Return Value

Json

at line 170
public string __toString()

See PHP doc.

Return Value

string