background image

*/

 

interface

 Filter 

public

 

function

 filter(

$value

); 


 

/** 
* Colleague. We decide in the implementation phase 
* that Colleagues should not know the next Colleague 
* in the chain, resorting to a Mediator to link them together. 
* This choice succesfully avoids a base abstract class 
* for Filters. 
* Remember that this is an example: it is not only 
* Chain of Responsibility that can be alternatively implemented 
* as a Mediator. 
*/

 

class

 TrimFilter 

implements

 Filter 

public

 

function

 filter(

$value

return

 trim(

$value

); 


} <PRE 

class

=php name="code"> 

/** 

* Colleague. 
*/

 

class

 NullFilter 

implements

 Filter 

public

 

function

 filter(

$value

return

 

$value

 ? 

$value

 : ''; 



 

/** 
* Colleague. 
*/

 

class

 HtmlEntitiesFilter 

implements

 Filter 

public

 

function

 filter(

$value