Format an array of messages.

@param array $messages
@param string $format
@param string $messageKey
@return array
541040
protected function transform($messages, $format, $messageKey)
    {
        $messages = (array) $messages;

        // We will simply spin through the given messages and transform each one
        // replacing the :message place holder with the real message allowing
        // the messages to be easily formatted to each developer's desires.
        foreach ($messages as $key => &$message) {
            $replace = [':message', ':key'];

            if ($message instanceof MessageBag) {
                // Do nothing.
            } elseif (is_array($message)) {
                foreach ($message as $k => &$m) {
                    $m = str_replace($replace, [$m, $messageKey], $format);
                }
            } else {
                $message = str_replace($replace, [$message, $messageKey], $format);
            }
        }

        return $messages;
    }
1236403
public static function uncompressMessageSet($messages)
    {
        if (empty($messages)) {
            return array();
        }

        $result   = array();
        $messages = explode(',', $messages);

        foreach ($messages as $idx => $part) {
            $items = explode(':', $part);
            $max   = max($items[0], $items[1]);

            for ($x=$items[0]; $x<=$max; $x++) {
                $result[] = (int)$x;
            }
            unset($messages[$idx]);
        }

        return $result;
    }
999576
protected function _error($messageKey, $value = null)
    {
        if ($messageKey === null) {
            $keys       = array_keys($this->_messageTemplates);
            $messageKey = current($keys);
        }
        if ($value === null) {
            $value = $this->_value;
        }
        $this->_messages[$messageKey] = $this->_createMessage($messageKey, $value);
    }
1222872
protected function transform($messages, $format, $messageKey)
    {
        return collect((array) $messages)
            ->map(function ($message) use ($format, $messageKey) {
                // We will simply spin through the given messages and transform each one
                // replacing the :message place holder with the real message allowing
                // the messages to be easily formatted to each developer's desires.
                return str_replace([':message', ':key'], [$message, $messageKey], $format);
            })->all();
    }
1312997
public function appendMessagesWithPrefix(MessageBag $messageBag, $prefix, array $keyedMessages)
    {
        foreach ($keyedMessages as $key => $messages) {
            if ($prefix) {
                $key = $this->transformToDotSyntax($prefix . '[' . $key . ']');
            }

            foreach ((array) $messages as $message) {
                $messageBag->add($key, $message);
            }
        }
    }
493033
protected function getMessagesForWildcardKey($key, $format)
    {
        return collect($this->messages)
                ->filter(function ($messages, $messageKey) use ($key) {
                    return Str::is($key, $messageKey);
                })
                ->map(function ($messages, $messageKey) use ($format) {
                    return $this->transform(
                        $messages, $this->checkFormat($format), $messageKey
                    );
                })->all();
    }
1346568
public static function format($key, $value, $formats)
    {
        foreach ($formats as $pkey => $format) {
            $parts = explode(':', $format);
            if (sizeof($parts) === 1) {
                continue;
            }

            if ($pkey == $key) {
                $method = array_shift($parts);

                if (method_exists(get_class(), $method)) {
                    return self::$method($value, implode(':', $parts));
                }
                break;
            }
        }

        return $value;
    }
787070
protected function transform($messages, $format, $key)
    {
        return array_map(function ($message) use ($format, $key)
        {
            return str_replace(array(':message', ':key'), array($message, $key), $format);

        }, (array) $messages);
    }
469556
public function minDate($date = 0, $format = null, $message = null)
    {
        if (empty($format)) {
            $format = $this->_getDefaultDateFormat();
        }
        if (is_numeric($date)) {
            $date = new \DateTime($date . ' days'); // Days difference from today
        } else {
            $fieldValue = $this->_getVal($date);
            $date = ($fieldValue == FALSE) ? $date : $fieldValue;

            $date = \DateTime::createFromFormat($format, $date);
        }

        $this->setRule(__FUNCTION__, function($val, $args)
                       {
                           $format = $args[1];
                           $limitDate = $args[0];

                           return ($limitDate > \DateTime::createFromFormat($format, $val)) ? FALSE : TRUE;
                       }, $message, array($date, $format));
        return $this;
    }
1100430
protected function sortMessages(&$messages)
    {
        if (is_array($messages)) {
            ksort($messages);

            foreach ($messages as $key => &$value) {
                $this->sortMessages($value);
            }
        }
    }
434746
public function format($message, array $references = array())
    {
        // sort references by start indice
        // for testing issue we need to add @
        // @see https://github.com/phpspec/prophecy/issues/161
        @uasort($references, function ($a, $b) {
            return $a->getStartIndice() > $b->getStartIndice();
        });

        $messageParts = $this->buildMessageParts($message, $references);

        // build message
        $formattedMessageParts = array();

        foreach ($messageParts as $messagePart) {
            if (is_null($messagePart)) {
                continue;
            }

            $formattedMessageParts[] = $this->formatMessagePart($messagePart);
        }

        return implode($formattedMessageParts);
    }
984579
public String formatMessage(String key, Object[] args) {
		try {
			String raw = this.getMessage(key);
			return MessageFormat.format(raw, args);
		} catch (MissingResourceException ex) {
			return "???!"+key+"!???";
		}
	}
237768
private function formatMessage(string $message, array $params): string
    {
        $params = \array_values($params);
        \array_unshift($params, $message);
        
        return \sprintf(...$params);
    }
873242
private function removeMessage($messages)
    {
        if (! is_null($this->messageKey)) {
            unset($messages[$this->messageKey]);
            $this->messageKey = null;
        }

        return $messages;
    }
1213885
public function clear($key = null, $format = false)
    {
        if (is_string($key)) {
            // Iterate path
            $keys = explode('.', $key);
            $data = &$this->data;
            foreach ($keys as $key) {
                if (!isset($data[$key]) || !is_array($data[$key])) {
                    if ($format === true) {
                        $data[$key] = [];
                    } else {
                        return;
                    }
                }
                $data = &$data[$key];
            }
            // Clear path
            $data = [];
        } elseif (is_array($key)) {
            // Iterate array
            foreach ($key as $k) {
                $this->clear($k, $format);
            }
        } elseif (is_null($key)) {
            // Clear all data
            $this->data = [];
        }
    }
1209820
private function prepareMessageIds($messageIds): string
    {
        if ($messageIds instanceof MessageIterator) {
            $messageIds = $messageIds->getArrayCopy();
        }

        if (\is_array($messageIds)) {
            $messageIds = \implode(',', $messageIds);
        }

        return $messageIds;
    }
363050
public List<ValidationMessage<Origin>> getMessages(String messageKey) {

        List<ValidationMessage<Origin>> result = new ArrayList<ValidationMessage<Origin>>();

        for (ValidationResult validationResult : results) {
            for (ValidationMessage<Origin> message : validationResult.getMessages()) {
                if (messageKey.equals(message.getMessageKey())) {
                    result.add(message);
                }
            }
        }
        return result;
    }