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
mixed
|
#
from( array $properties = null, array $construct_args = [], string|null $class_name = null )
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
array
|
#
__sleep( )
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
ICanBoogie\Prototyped
|
#
assign( array $properties )
Assigns properties to an object.
Assigns properties to an object.
Parameters
- $properties
- The properties to assign.
Returns
|
public
array
|
#
to_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
string
|
#
to_json( )
Converts the object into a JSON string.
Converts the object into a JSON string.
Returns
string
|