Clamp string length in arguments list

This commit is contained in:
filp
2013-04-12 14:03:44 +01:00
parent e552ed2b30
commit 8cfd27aa81
2 changed files with 10 additions and 1 deletions
+9
View File
@@ -111,6 +111,13 @@ class PrettyPageHandler extends Handler
return strtolower($_);
};
// $clamp -> clamp a string's length to a maximum, with trailing
// ellipsis if the size is exceeded
$clamp = function($_, $max = 85) {
return strlen($_) <= $max ?
$_ : (substr($_, 0, $max - 1) . '...');
};
// $type -> translate gettype to valid prettyprint class names
$type = function($_) {
static $map = array(
@@ -122,6 +129,8 @@ class PrettyPageHandler extends Handler
return isset($map[$_]) ? $map[$_] : $_;
};
// $trim ->
require $templateFile;
});
+1 -1
View File
@@ -106,7 +106,7 @@
<span class="argument-n"><?php echo $argN ?></span>
<code class="prettyprint <?php echo $type(gettype($arg)) ?>">
<?php if(is_string($arg)): ?>
"<?php echo $e($arg) ?>"
"<?php echo $e($clamp($arg)) ?>"
<?php elseif(is_object($arg)): ?>
&lt;<?php echo get_class($arg) ?>&gt;
<?php else: ?>