Format an array of messages.

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

		foreach ($messages as $key => &$message)
		{
			$message = str_replace(':message', $message, $format);
		}

		return $messages;
	}
159878
protected static function format_lesson_messages($lesson) {
        $messages = array();
        foreach ($lesson->messages as $message) {
            $messages[] = array(
                'message' => $message[0],
                'type' => $message[1],
            );
        }
        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;
    }
574909
protected function applyFormat($format, $data)
    {

        foreach ($format as $key => $value) {
            $meta = array_values(array_filter($this->formatting, function ($item) use ($value) {
                return $item['name'] === $value['function'] ? true : false;
            }));

            if ($meta && !array_key_exists('class', $value)) {
                $data = $this->applyDefaultFormat($value, $meta[0], $data);
            } else {
                $data = $this->applyCustomFormat($value, $data);
            }
        }

        return $data;
    }
1374908
public function jsonSerialize($format = self::JSON_DEFAULT_FORMAT)
    {
        $data = [
            'uid'        => $this->_uid,
            'label'      => $this->_label,
            'type'       => $this->getContentType(),
            'state'      => $this->_state,
            'created'    => $this->_created->getTimestamp(),
            'modified'   => $this->_modified->getTimestamp(),
            'revision'   => $this->_revision,
            'parameters' => $this->getAllParams(),
            'accept'     => array_map(
                function ($classname) {
                    return str_replace(NAMESPACE_SEPARATOR, '/', $classname);
                },
                self::getShortClassname($this->getAccept())
            ),
            'minentry'   => $this->getMinEntry(),
            'maxentry'   => $this->getMaxEntry(),
            'elements'   => $this->computeElementsToJson($this->getData()),
            'has_elements' => count($this->getData()) === 0 ? false : true,
            'extra'      => [],
        ];

        if (0 === count($data['parameters'])) {
            $data['parameters'] = new \ArrayObject();
        }

        return $this->formatJsonData($data, $format);
    }
646016
public function writeXLabels(array $Format = [])
    {
        $R = isset($Format["R"]) ? $Format["R"] : $this->pChartObject->FontColorR;
        $G = isset($Format["G"]) ? $Format["G"] : $this->pChartObject->FontColorG;
        $B = isset($Format["B"]) ? $Format["B"] : $this->pChartObject->FontColorB;
        $Alpha = isset($Format["Alpha"]) ? $Format["Alpha"] : $this->pChartObject->FontColorA;
        $Angle = isset($Format["Angle"]) ? $Format["Angle"] : 0;
        $Padding = isset($Format["Padding"]) ? $Format["Padding"] : 5;
        $Position = isset($Format["Position"]) ? $Format["Position"] : LABEL_POSITION_TOP;
        $Labels = isset($Format["Labels"]) ? $Format["Labels"] : null;
        $CountOffset = isset($Format["CountOffset"]) ? $Format["CountOffset"] : 0;

        if ($Labels != null && !is_array($Labels)) {
            $Label = $Labels;
            $Labels = [$Label];
        }

        $X0 = $this->pChartObject->GraphAreaX1;
        $XSize = ($this->pChartObject->GraphAreaX2 - $this->pChartObject->GraphAreaX1) / ($this->GridSizeX + 1);

        $Settings = ["Angle" => $Angle, "R" => $R, "G" => $G, "B" => $B, "Alpha" => $Alpha];
        if ($Position == LABEL_POSITION_TOP) {
            $YPos = $this->pChartObject->GraphAreaY1 - $Padding;
            if ($Angle == 0) {
                $Settings["Align"] = TEXT_ALIGN_BOTTOMMIDDLE;
            }
            if ($Angle != 0) {
                $Settings["Align"] = TEXT_ALIGN_MIDDLELEFT;
            }
        } elseif ($Position == LABEL_POSITION_BOTTOM) {
            $YPos = $this->pChartObject->GraphAreaY2 + $Padding;
            if ($Angle == 0) {
                $Settings["Align"] = TEXT_ALIGN_TOPMIDDLE;
            }
            if ($Angle != 0) {
                $Settings["Align"] = TEXT_ALIGN_MIDDLERIGHT;
            }
        } else {
            return -1;
        }
        for ($X = 0; $X <= $this->GridSizeX; $X++) {
            $XPos = floor($X0 + $X * $XSize + $XSize / 2);

            if ($Labels == null || !isset($Labels[$X])) {
                $Value = $X + $CountOffset;
            } else {
                $Value = $Labels[$X];
            }
            $this->pChartObject->drawText($XPos, $YPos, $Value, $Settings);
        }
    }
1159350
public function setDateFormat($formats) {

		if(false === is_array($formats)) {
			$formats = [$formats];
		}

		$this -> date_formats = $formats;

		return $this;
	}
873242
private function removeMessage($messages)
    {
        if (! is_null($this->messageKey)) {
            unset($messages[$this->messageKey]);
            $this->messageKey = null;
        }

        return $messages;
    }
1243211
public static function getMimeTypes($format)
    {
        if (null === static::$formats) {
            static::initializeFormats();
        }

        return isset(static::$formats[$format]) ? static::$formats[$format] : [];
    }
299595
public function setFormat($format) {
        if ($format === null) {
            $format = [];
        } else if ( ! is_array($format)) {
            $format = [$format];
        }

        $this->format = $format;

        return $this;
    }
44950
public function setFormat($format, $mimeTypes) {

		if (NULL === static::$formats) {
			static::initializeFormats();
		}

		static::$formats[$format] = is_array($mimeTypes) ? $mimeTypes : array($mimeTypes);

	}
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;
    }
659777
protected function formatMessage($message, $format = [Console::FG_RED, Console::BOLD])
    {
        $stream = (PHP_SAPI === 'cli') ? \STDERR : \STDOUT;
        // try controller first to allow check for --color switch
        if ($this->app->controller instanceof Controller && $this->app->controller->isColorEnabled($stream)
            || $this->app instanceof Application && Console::streamSupportsAnsiColors($stream)) {
            $message = Console::ansiFormat($message, $format);
        }

        return $message;
    }
858498
protected function translateMessages(array $messages)
    {
        $results = array();
        foreach( $messages as $message ) {
            $results[] = Translate::message($message);
        }

        return $results;
    }
775272
protected function getValidationMessagesForElements(array $messages = [])
    {
        $this->getElements()->onlyActive()->each(function ($element) use (&$messages) {
            $element = $this->getElementContainer($element);

            if ($element instanceof Validable) {
                $messages += $element->getValidationMessages();
            }
        });

        return $messages;
    }
50384
public function setMessages(array $messages)
    {
        foreach ($messages as $key => $message) {
            $this->setMessage($message, $key);
        }
        return $this;
    }
1247337
private function splitMessages(&$parsed, &$errors): array
    {
        // init
        $messages = [];
        $tmpmsg = [];
        $service = [];
        $hasInterchangeDelimiters = 0;
        $hasMessageDelimiters = 0;

        foreach ($parsed as $c => $segment) {
            switch ($segment[0]) {
                case 'UNB':
                    $hasInterchangeDelimiters = 0;
                    $hasInterchangeDelimiters++;
                    $service['UNB'] = $segment;
                    break;
                case 'UNZ':
                    $hasInterchangeDelimiters--;
                    if ($hasInterchangeDelimiters != 0) {
                        $sid = ($hasInterchangeDelimiters < 0) ? "UNB" : "UNZ";
                        $errors[] = [
                            "text"      => $this->messageTextConf['MISSINGINTERCHANGEDELIMITER'],
                            "position"  => $c,
                            "segmentId" => $sid,
                        ];
                    }
                    $service['UNZ'] = $segment;
                    break;
                case 'UNH':
                    $hasMessageDelimiters = 0;
                    $hasMessageDelimiters++;
                    $tmpmsg = [$segment];
                    break;
                case 'UNT':
                    $hasMessageDelimiters--;
                    $tmpmsg[] = $segment;
                    $messages[] = $tmpmsg;
                    if ($hasMessageDelimiters != 0) {
                        $sid = ($hasMessageDelimiters < 0) ? "UNH" : "UNT";
                        $errors[] = [
                            "text"      => $this->messageTextConf['MISSINGMESSAGEDELIMITER'],
                            "position"  => $c,
                            "segmentId" => $sid,
                        ];
                    }
                    break;
                default:
                    $tmpmsg[] = $segment;
                    break;
            }
        }

        if ($hasInterchangeDelimiters != 0) {
            $sid = ($hasInterchangeDelimiters < 0) ? "UNB" : "UNZ";
            $errors[] = [
                "text"      => $this->messageTextConf['MISSINGINTERCHANGEDELIMITER'],
                "position"  => $c ?? '',
                "segmentId" => $sid,
            ];
        }

        if ($hasMessageDelimiters != 0) {
            $sid = ($hasMessageDelimiters < 0) ? "UNH" : "UNT";
            $errors[] = [
                "text"      => $this->messageTextConf['MISSINGMESSAGEDELIMITER'],
                "position"  => $c ?? '',
                "segmentId" => $sid,
            ];
        }

        $messages['service'] = $service;

        return $messages;
    }