Consumes a message

@param string $message
@param array  $headers

@return mixed
542794
public function consume($message, array $headers = [])
    {
        $command = $this->deserializer->deserialize($message);
        return $this->commandBus->handle($command);
    }
902815
public function deserialize($message)
    {
        $serializedDomainMessageStream = @json_decode($message, true);

        if (json_last_error() !== JSON_ERROR_NONE) {
            throw new DeserializeException(json_last_error_msg());
        }

        try {
            Assertion::isArray($serializedDomainMessageStream);
        } catch (InvalidArgumentException $exception) {
            //@TODO remove this try catch in BC
            throw new DeserializeException($exception->getMessage(), $exception->getCode(), $exception);
        }

        $domainMessages = [];
        foreach ($serializedDomainMessageStream as $serializedDomainMessage) {
            $domainMessages[] = $this->serializer->deserialize($serializedDomainMessage);
        }

        return new DomainEventStream($domainMessages);
    }
991494
public static function parseHeaders($content, AbstractMessage $message)
    {
        $namespace = explode('\\', get_class($message));
        $name = strtoupper(array_pop($namespace));

        if (strpos($content, 'HTTP/') === 0 || strpos($content, $name) === 0) {
            $line = self::nibbleLine($content);
            if (preg_match('/^HTTP\/[0-9]{1}\.[0-9]{1} (?P<code>[0-9]+) (?P<message>.*)$/', $line, $matches) &&
                $matches["code"] == "100"
            ) {
                self::nibbleLine($content);
            }
            while (($line = self::nibbleLine($content)) != "") {
                if (preg_match('/^([A-Za-z\-]+): (.*)/', $line, $matches)) {
                    $message->addHeader($matches[1], $matches[2]);
                }
            }
        }

        return $content;
    }
798620
public function withError($message, $errorCode = 500, array $headers = [])
    {
        $data = [
            'status'  => false,
            'success' => false,
            'code'    => $errorCode ?: $this->getStatusCode(),
            'msg'     => $message,
            'error'   => [
                'code'      => $errorCode,
                'http_code' => $this->statusCode,
                'message'   => $message,
            ],
        ];

        return $this->response($data, $headers);
    }
742670
protected function respondWithSuccessMessage($data = [], $headers = [])
    {
        $response = [];
        $response['success'] = true;

        if (!empty($data)) {
            $response['response'] = $data;
        }

        return $this->respond($response, $headers);
    }
245463
private function parseHeaders(array $headers)
    {

        // Set the raw headers as we got from the constructor.
        $this->raw_headers = $headers;

        // flatten the headers array so that values are not arrays themselves
        // but rather simple key value pairs.
        $headers = array_map(function ($value) {

            if (! is_array($value))
                return $value;

            return implode(';', $value);
        }, $headers);

        // Set the parsed headers.
        $this->headers = $headers;

        // Check for some header values that might be interesting
        // such as the current error limit and number of pages
        // available.
        $this->hasHeader('X-Esi-Error-Limit-Remain') ?
            $this->error_limit = (int) $this->getHeader('X-Esi-Error-Limit-Remain') : null;

        $this->hasHeader('X-Pages') ? $this->pages = (int) $this->getHeader('X-Pages') : null;
    }
573613
public function msg(string $message = '', array $vars = [])
    {
        return $this->intuition->msg($message, [
            'domain' => $this->domain,
            'variables' => $vars,
        ]);
    }
237110
public static function alias(array $message) {
    self::checkClient();
    $userId = !empty($message["userId"]);
    $previousId = !empty($message["previousId"]);
    self::assert($userId && $previousId, "Segment::alias() requires both userId and previousId");

    return self::$client->alias($message);
  }
368633
private function getMessage(string $message): string
    {
        $hasTranslation = $this->messages !== null && array_key_exists($message, $this->messages) === false;

        return $hasTranslation === true ? $this->messages[$message] : $message;
    }
629779
public static function setHeader(array $message, $header, array $value)
    {
        $message = self::removeHeader($message, $header);
        $message['headers'][$header] = $value;

        return $message;
    }
712263
private function getMessageHeader(AMQPMessage $message, $header)
    {
        $headers = $message->has('application_headers') ? $message->get('application_headers') : [];

        return array_key_exists($header, $headers) ? $headers[$header] : null;
    }
119947
public function read($service, $headers = null, $data = null)
	{
		return $this->get($service, $headers, $data);
	}
722983
public function headers( array $headers )
      : Request
   {

      $this->_defaultHeaders = array_merge( $this->_defaultHeaders, $headers );

      return $this;

   }
1115370
public function headers(array $headers): HttpRequest
    {
        foreach ($headers as $name => $value) {
            $this->header($name, $value);
        }

        return $this;
    }
750560
protected function translateMessage($message, array $parameters = array())
    {
        return $this->translator->trans($message, $parameters, $this->transDomain);
    }
857086
public static function removeHeader(array $message, $header)
    {
        if (isset($message['headers'])) {
            foreach (array_keys($message['headers']) as $key) {
                if (!strcasecmp($header, $key)) {
                    unset($message['headers'][$key]);
                }
            }
        }

        return $message;
    }
433381
protected function handleMessage($message)
    {
        if (!is_null($response = $this->call('message.*', array($message)))) {
            return $response;
        }

        return $this->call("message.{$message['MsgType']}", array($message));
    }