I have to write the same piece of code again and again, and I'd like to know if there's a better way, or a shortcut
I'm using php, and I have 3 classes:
class A{
private $data = array( .... );
protected function get($index){
return $data[$index];
}
}
class B extends A{
}
class C extends B{
public function doSth(){
echo A::get('index');
}
}
What I want to do is to get data from the grandparent-class.
No problem, in except that I need to get data very often, and that the php-code gets extremly huge (the real classname is very long, and the getter-Functionname is very long)
That's what I'm writing:
databaseCore::getDataByIndex('name')
In C I would use a preprocessor-makro like this:
#define DATA(x) databaseCore::getDataByIndex((x))
Is there an easy way to reduce the amount of code I have to write?