Aggregation is the idea of one object using another object instance to invoke
some functionality, as opposed to inheritance. In PHP aggregation is currently
implemented by aggregation functions, which allow you to add methods to an
object at runtime.
Adding a method to Simple
<?php
class ParentClass {
function beamazing () {
print "I'm so amazing I must be aggregated!\n";
}
}
class ChildClass {
function simple () {
print "I'm simple and unamazing :(((\n";
}
}
$obj = new ChildClass;
var_dump ($obj);
aggregate($obj, 'ParentClass');
var_dump ($obj);
$obj->beamazing ();
?>