FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [View Raw Code]   [Original HTTPS Page]

DesignPatternsPHP/Behavioral/ChainOfResponsibilities at master · cinekk/DesignPatternsPHP · GitHub

Repository navigation

Latest commit

 

History

History
 
 
  1. DesignPatternsPHP
  2. Behavioral

ChainOfResponsibilities

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

README.rst

Purpose

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.

Examples

  • 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

UML Diagram

Code

You can also find this code on GitHub

Handler.php

.. literalinclude:: Handler.php
   :language: php
   :linenos:

Responsible/FastStorage.php

.. literalinclude:: Responsible/HttpInMemoryCacheHandler.php
   :language: php
   :linenos:

Responsible/SlowStorage.php

.. literalinclude:: Responsible/SlowDatabaseHandler.php
   :language: php
   :linenos:

Test

Tests/ChainTest.php

.. literalinclude:: Tests/ChainTest.php
   :language: php
   :linenos:


Back | FazBrowse Home | New Git URL