CoreFiles by mySites.guru
DataFormatter.php83 lines, 1,793 bytes, from Joomla_4.0.0-beta1-Beta-Full_Package.zip
Raw History Compare with 3.9.0-beta4
md5
66ed22d1b898bc91c09cee10e5d07e4c
sha1
1337f1caf2dbd12fe89fcf7eedc05191a22e606e
sha256
6f472b2ff142a59e006694fac94daa7b95e66c2a5c968a33f7bdad2d58df9ce0
<?php
/**
 * @package     Joomla.Plugin
 * @subpackage  System.Debug
 *
 * @copyright   Copyright (C) 2017 Open Source Matters, Inc. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

namespace Joomla\Plugin\System\Debug;

use DebugBar\DataFormatter\DataFormatter as DebugBarDataFormatter;

/**
 * DataFormatter
 *
 * @since  4.0.0
 */
class DataFormatter extends DebugBarDataFormatter
{
	/**
	 * Strip the root path.
	 *
	 * @param   string  $path         The path.
	 * @param   string  $replacement  The replacement
	 *
	 * @return string
	 *
	 * @since 4.0.0
	 */
	public function formatPath($path, $replacement = ''): string
	{
		return str_replace(JPATH_ROOT, $replacement, $path);
	}

	/**
	 * Format a string from back trace.
	 *
	 * @param   array  $call  The array to format
	 *
	 * @return string
	 *
	 * @since 4.0.0
	 */
	public function formatCallerInfo(array $call): string
	{
		$string = '';

		if (isset($call['class']))
		{
			// If entry has Class/Method print it.
			$string .= htmlspecialchars($call['class'] . $call['type'] . $call['function']) . '()';
		}
		elseif (isset($call['args']) && \is_array($call['args'][0]))
		{
			$string .= htmlspecialchars($call['function']) . ' (';

			foreach ($call['args'][0] as $arg)
			{
				// Check if the arguments can be used as string
				if (\is_object($arg) && !method_exists($arg, '__toString'))
				{
					$arg = \get_class($arg);
				}

				$string .= htmlspecialchars($arg) . ', ';
			}

			$string = rtrim($string, ', ') . ')';
		}
		elseif (isset($call['args']))
		{
			$string .= htmlspecialchars($call['function']) . ' ' . $call['args'][0];
		}
		else
		{
			// It's a function.
			$string .= htmlspecialchars($call['function']) . '()';
		}

		return $string;
	}
}

The same content is in 5 releases, Joomla 4.0.0-beta to 4.0.0-beta5. See them all, or every version of this file.