PHP Singleton Function Factory Generator.