Refactor utility functions for PHP debugging