Make a common function code template
Making the closure a static method to avoid error on 5.3
Move eval
Merge pull request #1 from jubianchi/phpMocker

Remove code duplication, thanks to @jubianchi for its help.