To build a chain of objects to handle a call in sequential order. If one object cannot handle a call, it delegates the call to the next in the chain and so forth.
- logging framework, where each chain element decides autonomously what to do with a log message
- a Spam filter
- Caching: first object is an instance of e.g. a Memcached Interface, if that "misses" it delegates the call to the database interface
You can also find this code on GitHub
Handler.php
Handler.php
Responsible/FastStorage.php
Responsible/HttpInMemoryCacheHandler.php
Responsible/SlowStorage.php
Responsible/SlowDatabaseHandler.php
Tests/ChainTest.php
Tests/ChainTest.php