Builds the actual body of the message

@param  \RMS\PushNotificationsBundle\Message\BlackberryMessage $message
@param $separator
@return string
760730
protected function constructMessageBody(BlackberryMessage $message, $separator)
    {
        $data = "";
        $messageID = microtime(true);

        $data .= "--" . $separator . "\r\n";
        $data .= "Content-Type: application/xml; charset=UTF-8\r\n\r\n";
        $data .= $this->getXMLBody($message, $messageID) . "\r\n";
        $data .= "--" . $separator . "\r\n";
        $data .= "Content-Type: text/plain\r\n";
        $data .= "Push-Message-ID: {$messageID}\r\n\r\n";
        if (is_array($message->getMessageBody())) {
            $data .= json_encode($message->getMessageBody());
        } else {
            $data .= $message->getMessageBody();
        }
        $data .= "\r\n";
        $data .= "--" . $separator . "--\r\n";

        return $data;
    }
28803
public function toHTML($separator = '<br/>') {
        $output = '';

        foreach ($this->diff as $entry) {
            $element = '';
            if ($entry instanceof UnmodifiedEntry) {
                $element = 'span';
            } elseif ($entry instanceof DeletedEntry) {
                $element = 'del';
            } elseif ($entry instanceof InsertedEntry) {
                $element = 'ins';
            }
            $output .= '<' . $element . '>' . $entry . '</' . $element . '>' . $separator;
        }

        return $output;
    }
974790
public function logAny($message, bool $separate = false): ?bool
    {
        return $this->log(self::ANY, $message, $separate);
    }
651008
private static function postProcessText($text, $separator)
    {
        if (function_exists('mb_strtolower')) {
            $text = mb_strtolower($text);
        } else {
            $text = strtolower($text);
        }

        // Remove all none word characters
        $text = preg_replace('/\W/', ' ', $text);

        // More stripping. Replace spaces with dashes
        $text = strtolower(preg_replace('/[^A-Za-z0-9\/]+/', $separator,
                           preg_replace('/([a-z\d])([A-Z])/', '\1_\2',
                           preg_replace('/([A-Z]+)([A-Z][a-z])/', '\1_\2',
                           preg_replace('/::/', '/', $text)))));

        return trim($text, $separator);
    }
1262182
public static function formatMessage($message): string
    {
        if ($message instanceof \Throwable) {
            while ($message) {
                $tmp[] = ($message instanceof \ErrorException
                        ? Helpers::errorTypeToString($message->getSeverity()) . ': ' . $message->getMessage()
                        : Helpers::getClass($message) . ': ' . $message->getMessage() . ($message->getCode() ? ' #' . $message->getCode() : '')
                    ) . ' in ' . $message->getFile() . ':' . $message->getLine();
                $message = $message->getPrevious();
            }
            $message = \implode("\ncaused by ", $tmp);

        } elseif (!\is_string($message)) {
            $message = self::toText($message);
        }

        return \trim($message);
    }
86178
public function substringAfterFirst($separator)
    {
        if (($offset = $this->indexOf($separator)) === false) {
            return false;
        }

        return static::create(mb_substr($this->str, $offset + mb_strlen($separator, $this->encoding), null, $this->encoding), $this->encoding);
    }
1299835
public function message($to, $message, $mediaUrls = null, array $params = [])
    {
        $params['body'] = $message;

        if (!isset($params['from'])) {
            $params['from'] = $this->from;
        }

        if (!empty($mediaUrls)) {
            $params['mediaUrl'] = $mediaUrls;
        }

        return $this->getTwilio()->messages->create($to, $params);
    }
1048464
private function buildContent(Swift_Mime_Message $message)
    {
        $content = [
            'subject' => $this->convertAsteriskPipeToCurlyBraces($message->getSubject()),
            'from'    => $this->buildFrom($message),
        ];

        if ($message->getReplyTo()) {
            $content['reply_to'] = key($message->getReplyTo());
        }

        $contentMap = ['text/html' => 'html', 'text/plain' => 'text'];

        $contentType = $this->readUserContentType($message);
        if (isset($contentMap[$contentType])) {
            $content[$contentMap[$contentType]] = $this->convertAsteriskPipeToCurlyBraces($message->getBody());
        }

        foreach ($message->getChildren() as $part) {
            if (!($part instanceof Swift_MimePart)) {
                continue;
            }

            $contentType = $part->getContentType();
            if (isset($contentMap[$contentType])) {
                $content[$contentMap[$contentType]] = $this->convertAsteriskPipeToCurlyBraces($part->getBody());
            }
        }

        if ($headers = $this->buildHeaders($message)) {
            $content['headers'] = $headers;
        }

        if ($attachments = $this->buildAttachments($message)) {
            $content['attachments'] = $attachments;
        }

        return $content;
    }
535625
public function split($separator)
    {
        $hash = new Hash(explode((string) $separator, (string) $this));

        return $hash->map(
            function ($value) {
                return new String($value);
            }
        );
    }
1134477
public static function getStringWithoutLastElement($string, $separator)
    {
        $elements = self::getStringElements($string, $separator);
        $lastKey = Arrays::getLastKey($elements);

        unset($elements[$lastKey]);

        return implode($separator, $elements);
    }
1235031
public static function createFromRaw($message)
    {
        $eventStart = strpos($message, 'Event: ') + 7;
        $eventEnd = strpos($message, Message::EOL, $eventStart);
        if ($eventEnd === false) {
            $eventEnd = strlen($message);
        }
        $name = substr($message, $eventStart, $eventEnd - $eventStart);
        $parts = explode('_', $name);
        $totalParts = count($parts);
        for ($i = 0; $i < $totalParts; $i++) {
            $parts[$i] = ucfirst($parts[$i]);
        }
        $name = implode($parts, '');
        $className = '\\PAMI\\Message\\Event\\' . $name . 'Event';
        if (class_exists($className, true)) {
            return new $className($message);
        }
        return new UnknownEvent($message);
    }
335994
public static function identifier(string $name, string $separator = '_'): string {
    $slugify    = new Slugify(['separator' => $separator]);
    $identifier = $slugify->slugify($name);

    return $identifier;
  }
816094
protected function getDecoratedMessage($message, $params = [])
    {
        $result = '';
        $prefix = '';
        foreach ($params as $option => $value) {
            if ($value) {
                $result .= $prefix . $this->decorations[$option][$value];
                $prefix = ';';
            }
        }

        if ($prefix) {
            $message = 'm' . $message;
        }

        return $result . $message;
    }
602372
private function buildPayload(Swift_Mime_Message $message)
    {
        try {
            return $this->payloadBuilder->buildPayload($message);
        } catch (AnyException $exception) {
            throw $this->createAndDispatchTransportException(
                'Failed to build payload for a SparkPost transmission',
                $exception
            );
        }
    }
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;
    }
25828
public function split($separator = null)
    {
        if (is_null($separator) === true) {
            return [$this->subject];
        }

        return new JArray(explode($separator, $this->subject));
    }
195268
protected function buildMessageParts($message, $references, $offset = 0)
    {
        $messageParts = array();

        // get first reference
        $reference = array_shift($references);

        if (!$reference) {
            return array(
                $this->buildMessagePart($message, 0, mb_strlen($message)),
            );
        }

        $messageParts[] = $this->buildMessagePart(
            $message,
            0,
            $reference->getStartIndice() - $offset
        );

        $messageParts[] = $this->buildMessagePart(
            $message,
            $reference->getStartIndice() - $offset,
            $reference->getEndIndice() - $offset,
            $reference
        );

        $message = mb_substr($message, $reference->getEndIndice() - $offset);

        foreach ($this->buildMessageParts($message, $references, $reference->getEndIndice()) as $messagePart) {
            $messageParts[] = $messagePart;
        };

        return $messageParts;
    }