I'm building a class which needs to have certain methods called by the
subclass, but the subclass can extend but not obscure/override the

So, for example, a method AuthRequestMade() will record the activity of
making an authorisation request. It cannot make the actual request as that
is the subclass's job, but, no matter what, I need to have this method
called with the result of the actual auth request.

I want to make building the subclasses as simple and as fool proof as

I think I have to do something like this ...

interface AuthEnforcer{
 public function AuthRequestMade(&$i_State, &$s_Message);

abstract class Auth implements AuthEnforcer{
 public method MakeAuthRequest(){
  // Do my stuff before.
  // Call the SpecificAuth class
  $this->AuthRequestMade($i_State, $s_Message);
  // Do my stuff after with state and message.

class SpecificAuth extends Auth{
 public function AuthRequestMade(&$i_State, &$s_Message){
  // Do my specific stuff, setting state and message.

But a couple of things I don't like (and don't know how to avoid).

1 - The SpecificAuth::AuthRequestMade is public and I want it protected as
it shouldn't be called from the public scope.
2 - The response is by ref, but I think having a AuthResponse class
containing $i_State and $s_Message should be enough there, but no way to
enforce return types in PHP.

Any ideas?

Thank you.

Richard Quadling
Twitter : @RQuadling
EE : http://e-e.com/M_248814.html
Zend : http://bit.ly/9O8vFY

Reply via email to