public static function to($Mixed, $FormatMethod)
{
// Process $Mixed based on its type.
if (is_string($Mixed)) {
if (in_array(strtolower($FormatMethod), self::$SanitizedFormats) && method_exists('Gdn_Format', $FormatMethod)) {
$Mixed = self::$FormatMethod($Mixed);
} elseif (function_exists('format' . $FormatMethod)) {
deprecated('format' . $FormatMethod, 'gdn_formatter_' . $FormatMethod, '2015-10-26');
$FormatMethod = 'format' . $FormatMethod;
$Mixed = $FormatMethod($Mixed);
} elseif (function_exists('gdn_formatter_' . $FormatMethod)) {
$FormatMethod = 'gdn_formatter_' . $FormatMethod;
$Mixed = $FormatMethod($Mixed);
} elseif ($Formatter = Gdn::factory($FormatMethod . 'Formatter')) {
$Mixed = $Formatter->format($Mixed);
} else {
$Mixed = Gdn_Format::text($Mixed);
}
} elseif (is_array($Mixed)) {
foreach ($Mixed as $Key => $Val) {
$Mixed[$Key] = self::to($Val, $FormatMethod);
}
} elseif (is_object($Mixed)) {
foreach (get_object_vars($Mixed) as $Prop => $Val) {
$Mixed->{$Prop} = self::to($Val, $FormatMethod);
}
}
return $Mixed;
}