trait ReflectorTrait

Basic implementation of the \Reflector::export() method

This trait defines a global export() method for objects that implement the \Reflector interface. The method will basically try to call current class constructor passing it the first argument received and then returns or echoes its representation.

Methods

static  string|null
export( mixed $argument, bool $return = false)

Creation of a new instance of the mother class on-the-fly

Details

at line 54
static string|null export( mixed $argument, bool $return = false)

Creation of a new instance of the mother class on-the-fly

Keep in mind that this method only consider the FIRST argument passed to transmit to the constructor. If your mother class requires more than one argument, you will have to over-write this method (or to not use the trait).

Parameters

mixed $argument
bool $return

Return Value

string|null

Exceptions

ErrorException if the mother class does not implement the \Reflector interface
ErrorException if the mother class constructor is not callable