Let's say I have something like this:
abstract class Parent
{
protected function foobar($data)
{
//do something with data
return $result;
}
}
class Child extends Parent
{
public function foobar()
{
$data = ...;
return parent::foobar($data);
}
}
As you can see, foobar is generically defined in Parent, and then Child passes class-specific data into the parent which returns the result. The reason this is done is because each child class of parent has its own data, but the method itself remains the same - only the parameter is different. The child also publicly exposes the method.
Is it a better idea to do something like this, where I create a method of the same name in both the parent and the child? Or should I maybe create a _foobar method in the Parent class and just have the Child's foobar method call that?