Design Patterns Java - Command Php

1) What have we got?

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


public class Receiver
{
    public void doA()
    {
        System.out.println("Receiver doing A");
    }

    public void doB()
    {
        System.out.println("Receiver doing B");
    }
}




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


public class Client
{
    public static void main(String[] args)
    {
        Receiver 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