public static function trim(Exception $exception)
{
$reflector = new ReflectionClass('Exception');
$traceProperty = $reflector->getProperty('trace');
$traceProperty->setAccessible(true);
$fileProperty = $reflector->getProperty('file');
$fileProperty->setAccessible(true);
$lineProperty = $reflector->getProperty('line');
$lineProperty->setAccessible(true);
$call = static::tracePhonyCall($traceProperty->getValue($exception));
if ($call) {
$traceProperty->setValue($exception, array($call));
$fileProperty->setValue($exception, isset($call['file']) ? $call['file'] : null);
$lineProperty->setValue($exception, isset($call['line']) ? $call['line'] : null);
} else {
$traceProperty->setValue($exception, array());
$fileProperty->setValue($exception, null);
$lineProperty->setValue($exception, null);
}
}