<? PHP /* ** Abstract policy roles, implemented using interfaces * interfaces only contain signatures for methods, delegates, or events; */ Interface Flyinterface { Public Function Fly ();} /* ** Specific policy a: Flying with wings */ Class Flywithwing Implements Flyinterface { Public Function Fly (){ Echo "I fly with wings \ n" ;}} /* ** Specific policy Role B: flight with foot */ Class Flywithfoot Implements Flyinterface { Public Function Fly (){ Echo "I fly with feet \ n";}} /* ** Primary role */ Class Duck { Private $ _ Fly ; Private $ _ Flyinterface = "Flywithwing" ; /* Referenced Policy */ Public Function _ Construct ( $ Flyinterface ){ If (! Empty ( $ Flyinterface )){ $ This -> _ Flyinterface = $ Flyinterface ;} $ This -> _ Fly = New $ This -> _ Flyinterface ;} Public Function Fly (){ $ This -> _ Fly-> Fly ();}} $ Ducka = New Duck ("flywithwing" ); $ Ducka -> Fly (); $ Duckb = New Duck ("flywithfoot" ); $ Duckb ->Fly (); ?>