I have a Method that does some jobs, a bit like this:
public function foo(array $ids)
{
$foos = $this->getAllFoos($ids);
$foos = $this->sortAllFoos($foos);
$filteredFoos = $this->filterOutsomeFoo($foos);
return $filteredFoos;
}
This function is a method used by the system. Now actual people want step by step insights on how we end up with the $filteredFoo
in order to double check wether it's done right. I'm looking for a method to do this gracefully.
- I can make a copy of this method and store everything in seperate values, but that'll become a maintance as I now need to make all changes twice, I dont like WET. I want DRY.
- I can pass an extra param like
foo(array $ids, &$debug = [])
and add a$debug['ids']=$ids
,$debug['foos']=$foos
,$debug['sortedFoos']=$sortedFoos
, but as my actual method is a bit larger, that nearly doubles the lines in my method.
Does anyone know a more elegant solution (I'm currently using option 2) which can be used?
Aucun commentaire:
Enregistrer un commentaire