Get method for message.

An exception will be thrown when method can not be found.

@param MessageInterface $message
@param string|null      $prefix
@return Closure
@throws MethodNotFound
161593
protected function getMethod(MessageInterface $message, string $prefix = null): Closure
    {
        $name = lcfirst($prefix . $message->getPayloadType()->getName());
        if (method_exists($this, $name) === false) {
            throw new MethodNotFound($message);
        }

        return (new ReflectionMethod($this, $name))->getClosure($this);
    }
1270517
public function setMessage(MessageInterface $message = null): ValidatorRuleInterface
    {
        $this->message = $message ?? $this->setupDefaultMessage();
        
        return $this;
    }
1246816
protected function dispatch($message, MessageCallback $callback) : void
    {
        $handled = false;
        foreach ($this->callableWrappersFor($message) as $callable) {
            $handled = true;
            if ($message instanceof PropagationStoppable && $message->isPropagationStopped()) {
                break;
            }
            try {
                $result = $callable->invoke($message);
                self::getLogger()->debug(
                    "The following message has been dispatched to handler '{}' through message bus '{}': {}",
                    [$callable, $this, $message]
                );
                if ($result !== null) {
                    $callback->onSuccess($result);
                }
            } catch (Exception $exp) {
                self::getLogger()->warn(
                    "An error occurred in the following message handler through message bus '{}': {}, message is {}!",
                    [$this, $callable, $message],
                    $exp
                );
                $context = new SubscriberExceptionContext($this, $message, $callable);
                try {
                    $this->exceptionHandler->handleException($exp, $context);
                } catch (Exception $e) {
                    self::getLogger()->error(
                        "An error occurred in the exception handler with context '{}'",
                        [$context],
                        $e
                    );
                }
                try {
                    $callback->onFailure($exp);
                } catch (Exception $e) {
                    self::getLogger()->error("An error occurred in message callback on bus '{}'", [$this], $e);
                }
            }
        }
        if (!$handled && !($message instanceof DeadMessage)) {
            self::getLogger()->debug(
                "The following message as a DeadMessage is being posted to '{}' message bus: {}",
                [$this, $message]
            );
            $this->dispatch(new DeadMessage($message), $callback);
        }
    }
352146
protected function guessRecipient(MessageContract $message)
    {
        if ($recipient = $message->recipient()) {
            return $recipient;
        }

        $swiftMessage = $this->getSwiftMessage($message);

        if (!$to = $swiftMessage->getTo()) {
            return null;
        }

        if (!count($to)) {
            return null;
        }

        return $to[0];
    }
992378
protected function buildClassEventCallback($class, $prefix)
	{
		list($class, $method) = $this->parseClassEvent($class, $prefix);

		// Once we have the class and method name, we can build the Closure to resolve
		// the instance out of the IoC container and call the method on it with the
		// given arguments that are passed to the Closure as the composer's data.
		return function() use ($class, $method)
		{
			$callable = array($this->container->make($class), $method);

			return call_user_func_array($callable, func_get_args());
		};
	}
124868
protected function getProviderHandler(Application $app, $prefix)
    {
        return function () use ($app, $prefix) {
            $initializer = $app["$prefix.client_initializer"];
            return $initializer($app);
        };
    }
868464
public function withMessage(string $message): PayloadInterface
    {
        if ($this->message === $message) {
            return $this;
        }

        $clone = clone $this;
        $clone->message = $message;

        return $clone;
    }
1096849
public function current(): MessageInterface
    {
        $current = parent::current();
        if (!\is_int($current)) {
            throw new Exception\OutOfBoundsException(\sprintf(
                'The current value "%s" isn\'t an integer and doesn\'t represent a message;'
                . ' try to cycle this "%s" with a native php function like foreach or with the method getArrayCopy(),'
                . ' or check it by calling the methods valid().',
                \is_object($current) ? \get_class($current) : \gettype($current),
                static::class
            ));
        }

        return new Message($this->resource, $current);
    }
732554
public function queue(Message $message, string $connectionName = null): MessageEnvelope
    {
        if (!$this->handles($message)) {
            throw new LogicException('Message of type ' . get_class($message) . " couldn't be handled by this notifier");
        }

        return $this->addToQueue($message, $connectionName);
    }
221519
public function assertStringStartsNotWith($prefix, $message = '')
    {
        Assert::assertStringStartsNotWith($prefix, $this->getData(), $message);

        return $this;
    }
677332
public static function methodCall(string $method, string $message, $_ = null) : InvalidOperationException
    {
        return self::formatArray('Invalid call to %s: ' . $message, array_merge([$method], array_slice(func_get_args(), 2)));
    }
723078
public function message($message=null) {
        if(is_null($message)) {
            return $this->message;
        }
        $this->message = $message;
    }
945112
private static function assertMessageClassSpecifiedInArguments(object $service, MessageHandler $handler): void
    {
        if (null === $handler->messageClass || '' === (string) $handler->messageClass)
        {
            throw new \LogicException(
                \sprintf(
                    'The message argument was not found in the "%s:%s" method',
                    \get_class($service),
                    $handler->methodName
                )
            );
        }
    }
1038897
public function gettext($message) {
		$args = func_get_args();
		$methodArgsNumber = 1;
		$message = $this->callMethodAndSprintf(__FUNCTION__, $args, $methodArgsNumber);
		return $message;
	}
1198831
protected function callMessageBuilder( $callback, $message )
	{
		if ( $callback instanceof Closure )
			return call_user_func( $callback, $message );

		if ( is_string( $callback ) )
			return UniversalBuilder::resolve( $callback )->mail( $message );

		throw new InvalidArgumentException( 'Callback is not valid.' );
	}
238480
public function call(MethodInterface $method)
    {
        $this->validator->validate($method);

        return $this->handleRequest($method);
    }
760584
public function assertStringStartsWith($prefix, $message = '')
    {
        Assert::assertStringStartsWith($prefix, $this->getData(), $message);

        return $this;
    }