Class Object
Together with the ICanBoogie\Prototype
class the ICanBoogie\Object
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\Object
implements
ICanBoogie\ToArrayRecursive
uses
ICanBoogie\ToArrayRecursiveTrait (not available)
ICanBoogie\PrototypeTrait
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 instance is created in the same fashion PDO
creates instances when fetching objects using the FETCH_CLASS
mode, that is the properties
of the instance are set before its constructor is invoked.
Note: Because the method uses the unserialize
function to create the instance, the __wakeup()
magic method will be called if it is
defined by the class, and it will be called before the constructor.
Note: The __wakeup() method of the ICanBoogie\Object
class removes null
properties
for which a getter is defined.
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
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()
,
__sleep()
,
accessor_get()
,
accessor_set()
,
get_prototype()
,
has_method()
,
has_property()
,
last_chance_get()
,
last_chance_set()
Properties summary
Magic properties