I have an abstract base class in my application.
I want to provide an factory()
method to allow me to make a new model easily with a static method.
public static function factory() {
$class = __CLASS__;
return new $class;
}
This obviously doesn't work as it tries to initiate the abstract class.
What I wanted to know, is how can I make classes which inherit this method initiate themselves and not the base class?
Do I have to pass the name of the model to the factory method?
PHP version is 5.2.13.