Class Prototyped
Together with the ICanBoogie\Prototype
class the ICanBoogie\Prototyped
class provides means to
define getters and setters, as well as define getters, setters, and method at runtime.
The class also provides a method to create instances in the same fashion PDO creates instances
with the FETCH_CLASS
mode, that is the properties of the instance are set before its
constructor is invoked.
-
ICanBoogie\Prototyped
implements
ICanBoogie\ToArrayRecursive
uses
ICanBoogie\ToArrayRecursiveTrait (not available)
ICanBoogie\PrototypeTrait,
ICanBoogie\Accessor\SerializableTrait (not available)
Methods summary
public static
from( array $properties
= null, array $construct_args
= [], string|null $class_name
= null )
: mixed
Creates a new instance of the class using the supplied properties.
Creates a new instance of the class using the supplied properties.
The method tries to create the instance in the same fashion as PDO
with the FETCH_CLASS
mode, that is the properties of the instance are set before its
constructor is invoked.
Parameters
$properties
- Properties to be set before the constructor is invoked.
$construct_args
- Arguments passed to the constructor.
$class_name
The name of the instance class. If empty, the name of the
called class is used.
Returns
mixed
The new instance.
public
__sleep( void )
: array
The method returns an array of key/key pairs.
The method returns an array of key/key pairs.
Properties for which a lazy getter is defined are discarded. For instance, if the property
next
is defined and the class of the instance defines the getter lazy_get_next()
, the
property is discarded.
Note that façade properties are also included.
Warning: The code used to export private properties seams to produce frameless exception on
session close. If you encounter this problem you might want to override the method. Don't
forget to remove the prototype property!
Returns
array
public
assign( array $properties
)
: ICanBoogie\Prototyped
Assigns properties to an object.
Assigns properties to an object.
Parameters
$properties
- The properties to assign.
Returns
public
to_array( void )
: array
Converts the object into an array.
Converts the object into an array.
Only public properties and façade properties are included.
Returns
array
public
to_json( void )
: string
Converts the object into a JSON string.
Converts the object into a JSON string.
Returns
string
__call()
,
accessor_get()
,
accessor_set()
,
get_prototype()
,
has_method()
,
has_property()
,
last_chance_get()
,
last_chance_set()
Properties summary
$prototype