izzum\statemachine\utils\Utils::checkCallable PHP Метод

checkCallable() публичный статический Метод

public static checkCallable ( callable $callable, string $type, string $info, Context $context = null ) : boolean
$callable callable
$type string a type description of the callable eg: State::CALLABLE_ENTRY
$info string extra info for exception message purposes
$context izzum\statemachine\Context optional: the context the callable is called in
Результат boolean
    public static function checkCallable($callable, $type, $info, $context = null)
    {
        if ($callable !== null && !is_callable($callable)) {
            throw new Exception(sprintf("not a valid '%s' callable for '%s'. %s", $type, $info, $context), Exception::CALLABLE_FAILURE);
        }
        return true;
    }

Usage Example

 /**
  * calls the $callable as part of the transition
  * @param callable $callable
  * @param Context $context
  * @throws Exception in case of an invalid callable
  */
 protected function callCallable($callable, Context $context, $type = 'n/a')
 {
     //in case it is a guard callable we need to return true/false
     if ($callable != self::CALLABLE_NULL) {
         Utils::checkCallable($callable, $type, "transition: " . $this, $context);
         return (bool) call_user_func($callable, $context->getEntity());
     }
     return true;
 }
All Usage Examples Of izzum\statemachine\utils\Utils::checkCallable