Re: Enforce a constant in a class.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2010/1/22 Darren Karstens <darrenkarstens@xxxxxxxxxxxxxx>:
> One way to do it would be to use getter functions in your interface
> that return the value of the constant (or a member variable) in your
> implemented class. For example:
>
> interface SetKillSwitch {
>       public function getKillSwitchNotes();
> }
>
> Then in your class implement your getKillSwitchNotes function:
>
> class KilledClass implements SetKillSwitch {
>       const KILL_SWITCH_NOTES = 'Some notes';
>
>      public function getKillSwitchNotes()
>      {
>          return SetKillSwitch::KILL_SWITCH_NOTES;
>      }
> }
>

The killswitch is something I want to tag to a class (KILL_SWITCH_SET)

The class itself will have to be documented as to why it has been
killed off (KILLED_ON and KILL_SWITCH_NOTES).




-- 
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux