Some kind of HBCI pagination.

@param AbstractMessage $message

@return array
333817
public function getTouchDowns(AbstractMessage $message)
    {
        $touchdown = array();
        $messageSegments = $message->getEncryptedSegments();
        /** @var AbstractSegment $msgSeg */
        foreach ($messageSegments as $msgSeg) {
            $segment = $this->findSegmentForReference('HIRMS', $msgSeg);
            if (null != $segment) {
                $parts = $this->splitSegment($segment);
                // remove header
                array_shift($parts);
                foreach ($parts as $p) {
                    $pSplit = $this->splitDeg($p);
                    if ($pSplit[0] == 3040) {
                        $td = $pSplit[3];
                        $touchdown[$msgSeg->getName()] = $td;
                    }
                }
            }
        }

        return $touchdown;
    }
620321
public function transformMessages(array $messages)
    {
        $transformed = null;

        if(count($messages))
        {
            $transformed = [];

            foreach ($messages as $message)
            {
                $attributes = (object) $message->getAttributes();

                $attributes->timestamp = $attributes->t;

                unset($attributes->t);
                
                // Add encryption check 
                $child = is_null($message->getChild(1)) ? $message->getChild(0) : $message->getChild(1);

                $node = new stdClass();
                $node->tag = $child->getTag();
                $node->attributes = (object) $child->getAttributes();
                $node->data = $child->getData();

                $attributes->body = $node;

                if($attributes->type == 'media')
                {
                    if($attributes->body->attributes->type == 'vcard')
                    {
                        $vcard = new VCardReader(null, $child->getChild(0)->getData());

                        if(count($vcard) == 1)
                        {
                            $attributes->body->vcard[] = $vcard->parse($vcard);
                        }
                        else
                        {
                            foreach ($vcard as $card)
                            {
                                $attributes->body->vcard[] = $vcard->parse($card);
                            }
                        }
                    }
                    else
                    {
                        $tmp = $this->media->link($attributes);
                    
                        $attributes->body->file = $tmp->file;
                        $attributes->body->html = $tmp->html;
                        $attributes->body->attributes2 = $node->attributes;
                    }           
                }

                $transformed[] = $attributes;
            }
        }

        return $transformed;
    }
862005
private function formatNewsForPush (News $message)
    {
        $articles = [];

        foreach ($message->getItems() as $item) {
            $article = [
                'title' => $item->getTitle(),
                'description' => $item->getDescription(),
            ];
            
            if ($item->getURL() !== null) {
                $article['url'] = $item->getURL();
            }
            
            if ($item->getImageURL() !== null) {
                $article['picurl'] = $item->getImageURL();
            }
            
            $articles[] = $article;
        }

        return ['articles' => $articles];
    }
1260481
private function getMessageLineCount($message)
    {
        $messageLength = FormatterHelper::strlenWithoutDecoration($this->output->getFormatter(), $message);

        return ceil($messageLength / $this->getTerminalWidth());
    }
761421
public function getOrders(OrderListMessage $message): array
    {
        $path = 'orders';

        $response = $this->getClient()->sendRequest('GET', $path, $message->build());

        /** @var Order[] $models */
        $models = $this->getModelFactory()->createMany(Order::class, $response['data']);

        return $models;
    }
18722
public function transformTextCard(AbstractMessage $message)
    {
        return [
            'msgtype'  => 'textcard',
            'textcard' => [
                'title'       => $message->get('title'),
                'description' => $message->get('description'),
                'url'         => $message->get('url'),
                'btntxt'      => $message->get('btntxt'),
            ],
        ];
    }
1359012
public function resolveCustomMessage($message)
    {
        preg_match_all('/\{[\w.| ]+\}/', $message, $segments);
        foreach (current($segments) as $segment) {
            $s    = str_replace(['{', '}'], '', $segment);
            $keys = explode('|', $s);

            if (empty($keys[1]) && isset($keys[2])) {
                $keys[1] = $this->callback($keys[2]);
            }

            $valueSegmented = $this->getValueSegmented($this, $keys[0], isset($keys[1]) ? $keys[1] : false);
            if (!$valueSegmented) {
                return false;
            }
            $message = str_replace($segment, $valueSegmented, $message);
        }

        return $message;
    }
1076314
protected static function findUserDefinedHeaders(Swift_Mime_Message $message)
    {
        $messageHeaders = $message->getHeaders();
        $userDefinedHeaders = [];
        /* At this moment $messageHeaders is left with non-Mailjet specific headers
         *
         */
        /** @var \Swift_Mime_Headers_AbstractHeader $header */
        foreach ($messageHeaders->getAll() as $header) {
            if (0 === strpos($header->getFieldName(), 'X-')) {
                $userDefinedHeaders[$header->getFieldName()] = $header->getFieldBody();
            }
        }

        return $userDefinedHeaders;
    }
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;
    }
487227
public function transformTransfer(AbstractMessage $message)
    {
        $response = [];

        // 指定客服
        if ($message->get('account')) {
            $response['TransInfo'] = [
                'KfAccount' => $message->get('account'),
            ];
        }

        return $response;
    }
1226122
public static function padMessage($message)
    {
        $messageLen = strlen($message);
        $padLen = self::MAX_MESSAGE_LENGTH - $messageLen;

        return pack('n*', $padLen).str_pad($message, $padLen + $messageLen, chr(0), STR_PAD_LEFT);
    }
812380
public function sendMessage(string $message) : ?Message 
    {
        $data = (object)[
            'messageEventDetail' => (object)[
                'eventCategoryCode' => MessageType::Text, 
                'messageDetail' => (object)[
                    'body' => $message
                ]
            ]
        ];

        $parameters = [
            [
                'name' => 'messageEventDetail',
                'contents' => json_encode($data, JSON_PRETTY_PRINT),
                'headers' => [
                    'Content-Type' => 'application/json; charset=utf-8'
                ]
            ]
        ];

        $response = $this->postMultiPart(sprintf(MessageThread::MESSAGE_THREAD_ENDPOINT . 'threads/%s/messages', $this->messageThreadId), $parameters);

        $messageFields = $this->info(1, true);

        if (!isset($messageFields->threadEvents)) return null;

        $messageData = $messageFields->threadEvents[0];

        return new Message($this->client, $messageData->messageEventDetail, $this);
    }
1013053
public function split(Message $message) : array
    {
        $splittedMessages = [];
        $messageName      = $message->getHeaders()->get(MessageFlowModule::INTEGRATION_MESSAGING_CQRS_MESSAGE_NAME_HEADER);

        foreach($this->messageFlowMapper->getFlowRegistrationsFor($messageName) as $messageFlowRegistration) {
            $registrationMessage     = MessageBuilder::fromMessage($message)
                ->setHeader(MessageFlowModule::INTEGRATION_MESSAGING_CQRS_MESSAGE_FLOW_REGISTRATION_HEADER, $messageFlowRegistration);

            if (!$messageFlowRegistration->isExternalFlow()) {
                $registrationMessage = $registrationMessage
                    ->setHeader(MessageFlowModule::INTEGRATION_MESSAGING_CQRS_MESSAGE_CLASS_HEADER, $messageFlowRegistration->getMessageClassName());
            }

            $splittedMessages[] = $registrationMessage
                                    ->build();
        }

        return $splittedMessages;
    }
1370359
public function getImagesUrls(array $message)
    {
        return Collection::make($message['message']['attachments'])->where('type',
            'image')->pluck('payload')->map(function ($item) {
                return new Image($item['url'], $item);
            })->toArray();
    }
937607
public function postMessage(Message $message)
    {
        $options = [
            'text' => $message->getText(),
            'channel' => $message->data['channel'],
            'as_user' => true,
        ];

        if ($message->hasAttachments()) {
            $options['attachments'] = json_encode($message->getAttachments());
        }

        return $this->apiCall('chat.postMessage', $options);
    }
800460
public function preparePayload(Message $message)
    {
        $payload = [
            'text' => $message->getText(),
            'channel' => $message->getChannel(),
            'username' => $message->getUsername(),
            'link_names' => $this->getLinkNames() ? 1 : 0,
            'unfurl_links' => $this->getUnfurlLinks(),
            'unfurl_media' => $this->getUnfurlMedia(),
            'mrkdwn' => $message->getAllowMarkdown(),
        ];

        if ($icon = $message->getIcon()) {
            $payload[$message->getIconType()] = $icon;
        }

        $payload['attachments'] = $this->getAttachmentsAsArrays($message);

        return $payload;
    }
967788
public function loadMessageXml(string $message_xml_file): array
    {
        $messageXmlString = \file_get_contents($message_xml_file);
        $messageXml = new \SimpleXMLIterator($messageXmlString);
        unset($messageXmlString);
        $message = [
            "defaults" => $this->readMessageDefaults($messageXml),
            "segments" => $this->readXmlNodes($messageXml),
        ];
        unset($messageXml);

        return $message;
    }