Tuesday 15 May 2012

php - reflection class to confirm class object -


So I understand that I can not type a gesture that can be in a class, so I thought I can take advantage of the Reflection API It may be bad behavior normally but that is what it is. Anyway, here's my layout basically, without using a reflection class, do we point to different types of methods? Is this a good way to deal with this situation?

  Interface Power {} class applies MPA Power {} class cPower implies Power {} class model ApiModel {function __construct (stdClass $ powerObj) {$ Po = new reflection ($ powerObj) ); If (in_array ('power', $ po-> getInterfaceNames ()) {// do something}}}    

About example operator

  function __construct ($ powerObj) {if ($ powerObj instanceof Power) {// Do Stuff}}   

In addition, since everything is sharing a common interface. You can type it:

  function __ composition (power $ powerObj) {// do stuff}    

No comments:

Post a Comment