I have two classes ClassA and ClassB. ClassA always needs an template file name, and ClassB extends ClassA.
In usual cases when a ClassB instance is created, the user has to specify the template file name. Like:
$classB = new ClassB('index');
But now I created a ClassX which extends ClassA, and when the user uses ClassX, he must not specify anything. It's a class that just creates a button, so it knows by itself what the template file for this is like.
So the user just wants to call:
$bttn = new ClassX();
and internally the constructor of ClassA is called with 'button_template'.
To do this, I see these choices:
A)
public function __construct() {
$tplName = func_get_arg(0);
if (!isset($tplName)) {
$tplName = 'button_template';
}
parent::__construct($tplName);
}
Or B)
public function __construct($tplName='button_template') {
if (!isset($tplName)) {
$tplName = 'index';
}
parent::__construct($tplName);
}
Or C)
public function __construct($tplName='button_template') {
parent::__construct($tplName);
}
Which one is the best? And why?