I have a class A
which needs a new method if one of its arguments is set up to true
.
Class A
Class A{
private $is_new_method;
public function __construct( $is_new_method = false, $new_method_name = "" ){
$this->is_new_method = $is_new_method;
if( $this->is_new_method ){
//TODO : add new method in this class based on $new_method_name
}
}
}
I saw runkit_method_add but it needs (PECL runkit >= 0.7.0).
Notice: this function will be call inside a core of a framework like this :
$foo = new A();
$foo->myNewFunction();
So what is the best way to do this ?