Created
June 24, 2014 22:30
-
-
Save webbower/03cc881e6289fa1f3e18 to your computer and use it in GitHub Desktop.
Functional utility function to wrap a declared function in a passable variable for chaining (PHP 5.3- version)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function lambdafy($funcname) { | |
if (function_exists($funcname)) { | |
return function() use ($funcname) { | |
return call_user_func_array($funcname, func_get_args()); | |
}; | |
} | |
throw new ErrorException('Catchable fatal error: Argument 1 passed to lambdafy() must be callable, string given', E_RECOVERABLE_ERROR); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment