trait MagicTrait

Trait MagicTrait. Contains magic methods: setter, getter, isset, call and has To reduce code on pure PHP classes with good practices and recomendations.

Methods

bool
__isset(string $key)

Magic isset.

mixed|null
__get(string $key)

Magic getter.

__set(string $key, mixed $value)

Magic setter.

$this|bool|mixed|string|null
__call(string $method, array $params)

Intercepts calls to non-existent getters / setters Looks at the beginning of $method to see if it's "get", "set", "has" Uses preg_match() to extract the 2nd part of the match, which should produce the property name

Details

at line 26
bool __isset(string $key)

Magic isset.

Parameters

string $key

Return Value

bool

at line 38
mixed|null __get(string $key)

Magic getter.

Parameters

string $key

Return Value

mixed|null

at line 51
__set(string $key, mixed $value)

Magic setter.

Parameters

string $key
mixed $value

at line 72
$this|bool|mixed|string|null __call(string $method, array $params)

Intercepts calls to non-existent getters / setters Looks at the beginning of $method to see if it's "get", "set", "has" Uses preg_match() to extract the 2nd part of the match, which should produce the property name

Parameters

string $method
array $params

Return Value

$this|bool|mixed|string|null

Exceptions

RuntimeException