Bolt\Routing\CallbackResolver::isValid PHP Method

isValid() public method

Returns true if the string is a valid service method representation or if the string/array references a class contained in the resolver's classmap.
public isValid ( string $name ) : boolean
$name string
return boolean
    public function isValid($name)
    {
        if (parent::isValid($name)) {
            return true;
        }
        if (is_array($name)) {
            list($cls, $method) = $name;
            if (is_object($cls)) {
                return false;
                // No need to convert
            }
            if (is_array($method)) {
                return true;
                // Need to convert
            }
        } elseif (is_string($name) && strpos($name, '::') > 0) {
            list($cls, $method) = explode('::', $name);
        } else {
            return false;
            // Can't handle this, maybe already callable
        }
        if (isset($this->classmap[$cls])) {
            return true;
            // Will use service definition
        }
        if (!class_exists($cls) || !method_exists($cls, $method)) {
            return false;
            // Can't handle this
        }
        $refMethod = new \ReflectionMethod($cls, $method);
        if ($refMethod->isStatic()) {
            return false;
            // Already valid
        }
        $constructor = $refMethod->getDeclaringClass()->getConstructor();
        // We can create the class if no constructor params, else can't handle it
        return $constructor === null || $constructor->getNumberOfRequiredParameters() === 0;
    }