1) What do we have ?
We have two classes implementing some functionality.
class "ParentA" - implements "doA"
and class "ParentB" implements "doB"
public function doA()
echo 'doing A ' . PHP_EOL;
public function doB()
echo 'doing B ' . PHP_EOL;
2) What want we to achieve ?
We want to use in "Child" class both implementation of "ParentA" alike implementation of "ParentB"
Let's look on class "Child"
class Child extends ParentA //, ParentB
Unfortunately/fortunately there is no possible multiple inheritance
2) How can we achieve our goal ?
We create interface which defining "doA" so the class "ParantA" implements this interface
"Child" class will implement the same interface, we aggregate into it object of "ParentA" and with this object we will implement interface "ParentA".
And all other methods we easily can modify lub add new, so in the other words we will decorate "ParentA" with class "ParentB"