src/Charcoal/Admin/Script/Object/Table/AlterPrimaryKeyScript.php
public function parseIdGenerator($callable)
    {
        if ($callable instanceof Closure) {
            return $callable;
        }

        $class    = null;
        $method   = null;
        $isMethod = false;
        $isModel  = false;
        $bail     = false;

        if (is_array($callable) && count($callable) === 2) {
            list($class, $func) = $callable;
            $isMethod = ($class && $func);
        } elseif (is_string($callable) && strpos($callable, '::') > 1) {
            list($class, $func) = explode('::', $callable);
            $isMethod = ($class && $func);
        }

        if ($isMethod) {
            $model   = $this->targetModel();
            $isModel = is_a($model, $class);

            $method = new ReflectionMethod($class, $func);
            if ($isModel && $method->isPublic()) {
                return $method->getClosure($model);
            } elseif ($method->isStatic() && $method->isPublic()) {
                return $callable;
            } else {
                $bail = true;
            }
        }

        if ($bail || !(is_string($callable) && function_exists($callable))) {
            throw new InvalidArgumentException(
                sprintf(
                    'The ID generator must be callable, received: %s',
                    is_object($callable)
                        ? get_class($callable)
                        : (is_string($callable)
                            ? $callable
                            : gettype($callable)
                        )
                )
            );
        }

        return $callable;
    }
public function parseIdGenerator($callable)
    {
        if ($callable instanceof Closure) {
            return $callable;
        }

        $class    = null;
        $method   = null;
        $isMethod = false;
        $isModel  = false;
        $bail     = false;

        if (is_array($callable) && count($callable) === 2) {
            list($class, $func) = $callable;
            $isMethod = ($class && $func);
        } elseif (is_string($callable) && strpos($callable, '::') > 1) {
            list($class, $func) = explode('::', $callable);
            $isMethod = ($class && $func);
        }

        if ($isMethod) {
            $model   = $this->targetModel();
            $isModel = is_a($model, $class);

            $method = new ReflectionMethod($class, $func);
            if ($isModel && $method->isPublic()) {
                return $method->getClosure($model);
            } elseif ($method->isStatic() && $method->isPublic()) {
                return $callable;
            } else {
                $bail = true;
            }
        }

        if ($bail || !(is_string($callable) && function_exists($callable))) {
            throw new InvalidArgumentException(
                sprintf(
                    'The ID generator must be callable, received: %s',
                    is_object($callable)
                        ? get_class($callable)
                        : (is_string($callable)
                            ? $callable
                            : gettype($callable)
                        )
                )
            );
        }

        return $callable;
    }
public function parseIdGenerator ( $ callable ) { if ( $ callable instanceof Closure ) { return $ callable ; } $ class = null ; $ method = null ; $ isMethod = false ; $ isModel = false ; $ bail = false ; if ( is_array ( $ callable ) && count ( $ callable ) === 2 ) { list ( $ class , $ func ) = $ callable ; $ isMethod = ( $ class && $ func ) ; } elseif ( is_string ( $ callable ) && strpos ( $ callable , '::' ) > 1 ) { list ( $ class , $ func ) = explode ( '::' , $ callable ) ; $ isMethod = ( $ class && $ func ) ; } if ( $ isMethod ) { $ model = $ this -> targetModel ( ) ; $ isModel = is_a ( $ model , $ class ) ; $ method = new ReflectionMethod ( $ class , $ func ) ; if ( $ isModel && $ method -> isPublic ( ) ) { return $ method -> getClosure ( $ model ) ; } elseif ( $ method -> isStatic ( ) && $ method -> isPublic ( ) ) { return $ callable ; } else { $ bail = true ; } } if ( $ bail || ! ( is_string ( $ callable ) && function_exists ( $ callable ) ) ) { throw new InvalidArgumentException ( sprintf ( 'The ID generator must be callable, received: %s' , is_object ( $ callable ) ? get_class ( $ callable ) : ( is_string ( $ callable ) ? $ callable : gettype ( $ callable ) ) ) ) ; } return $ callable ; }
Parse and validate the given function is callable.

@param  mixed $callable A function or method.
@throws InvalidArgumentException If the given argument is not a callable function.
@return callable
Parse and validate the given function is callable .