public function Exporter::shortenedExport in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/sebastian/exporter/src/Exporter.php \SebastianBergmann\Exporter\Exporter::shortenedExport()
Exports a value into a single-line string
The output of this method is similar to the output of SebastianBergmann\Exporter\Exporter::export. This method guarantees thought that the result contains now newlines.
Newlines are replaced by the visible string '\n'. Contents of arrays and objects (if any) are replaced by '...'.
Parameters
mixed $value:
Return value
string
See also
SebastianBergmann\Exporter\Exporter::export
File
- vendor/
sebastian/ exporter/ src/ Exporter.php, line 102
Class
- Exporter
- A nifty utility for visualizing PHP variables.
Namespace
SebastianBergmann\ExporterCode
public function shortenedExport($value) {
if (is_string($value)) {
$string = $this
->export($value);
if (strlen($string) > 40) {
$string = substr($string, 0, 30) . '...' . substr($string, -7);
}
return str_replace("\n", '\\n', $string);
}
if (is_object($value)) {
return sprintf('%s Object (%s)', get_class($value), count($this
->toArray($value)) > 0 ? '...' : '');
}
if (is_array($value)) {
return sprintf('Array (%s)', count($value) > 0 ? '...' : '');
}
return $this
->export($value);
}