/** * Gets a "safe string" from a `\DateTime` or an array * * @param mixed $source * @return string */ public static function getSafeString($source) { $str = $source; if (!is_string($source)) { if ($source instanceof \DateTime) { $str = Kernel::applyConfig('date_to_string', array($source)); } elseif (is_array($source)) { $str = ''; foreach ($source as $var => $val) { $str .= $var . ': ' . self::getSafeString($val) . PHP_EOL; } } } return $str; }