The responsibility chain mode is a behavior mode that contains some command objects and a series of processing objects. Each processing object determines which command objects it can process. The responsible chain mode is a behavior mode, which contains some command objects and a series of processing objects. Each processing object determines which command objects it can process, and it also knows how to pass the command objects that it cannot process to the next processing object in the chain. This mode also describes how to add a new processing object to the end of the processing chain.
Primary role
Abstract Responsibility role: defines public methods supported by all responsibilities.
Concrete Responsibility role: the specific Responsibility implemented by the abstract Responsibility interface
Chain of responsibility role: Set the call rule for the responsibility
Class diagram
Instance
Next = $ l; return $ this;} abstract public function operate (); // operation method} class ResponsibilityA extends Responsibility {public function _ construct () {} public function operate () {if (false = is_null ($ this-> next) {$ this-> next-> operate ();}};} class ResponsibilityB extends Responsibility {public function _ construct () {} public function operate () {if (false = is_null ($ this-> next )) {$ this-> next- > Operate () ;};}$ res_a = new ResponsibilityA (); $ res_ B = new ResponsibilityB (); $ res_a-> setNext ($ res_ B);?>