My colleague likes to write classes containing methods looking like this:
public function doTaskA()
{
return $this->doTask('A');
}
public function doTaskB()
{
return $this->doTask('B');
}
private function doTask($task)
{
...
I say this is bad practice, and would prefer to just make the doTask method public. I think if you really feel it is necessary to hardcode the possible values of $task in the class, then just make them class constants and call doTask(self::TASK_A) rather than writing a new function purely as a wrapper.
The worst case I saw of this, was a class with more than a dozen of these wrappers, and the doTask method was barely twenty lines long.
So, is this actually bad practice? Or is it just a matter of style? Or am I wrong, and it is actually considered good practice, as he insists?