Design Patterns PHP - Command Java

1) What have we got?

We have some object "Receiver" which has two methods: "doA" and "doB"


class Receiver
{
    public function doA()
    {
        echo 'Receiver doing A' . PHP_EOL;
    }

    public function doB()
    {
        echo 'Receiver doing B' . PHP_EOL;
    }
}




We very often just call method "doA" and "doB" in Client


$receiver = new Receiver();

$receiver->doA();
$receiver->doB();




2) What we want to do?

Let's imagine that we want to do something more than calling method.

For example we would like to log calling this method or save it in history or just queueing of calling method.

3) What can we do?

Let's see this on example of simple "Logger" which log when method call