src/Functions.php
public static function before($count, $function)
    {
        $memo = null;

        return function () use ($function, &$count, &$memo) {
            if (--$count > 0) {
                $args = func_get_args();
                $memo = call_user_func_array($function, $args);
            }

            return $memo;
        };
    }
public static function before($count, $function)
    {
        $memo = null;

        return function () use ($function, &$count, &$memo) {
            if (--$count > 0) {
                $args = func_get_args();
                $memo = call_user_func_array($function, $args);
            }

            return $memo;
        };
    }
public static function before ( $ count , $ function ) { $ memo = null ; return function ( ) use ( $ function , & $ count , & $ memo ) { if ( -- $ count > 0 ) { $ args = func_get_args ( ) ; $ memo = call_user_func_array ( $ function , $ args ) ; } return $ memo ; } ; }
Creates a version of the function that can be called no more than count times.

The result of the last function call is memoized and returned when count has been reached.

@param integer  $count
@param callable $function
@return \Closure
Creates a version of the function that can be called no more than count times .