Design Patterns PHP - Strategy Java

1) What have we got at the beginning?

Let's imagine that we have one class "Context"

And two methods "doA" and "doB"


class Context
{
    public function doA()
    {
        echo 'DoingA ver1' . PHP_EOL;
    }

    public function doB()
    {
        echo 'DoingB ver1' . PHP_EOL;
    }
}




2) Assumptions?

Yes, we often want to change behaviour of method "doA" and "doB" in application

What can we do?

We can inherit from class "Context" let's see this in example: