for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* This file is part of the BEAR.Package package.
*
* @license http://opensource.org/licenses/MIT MIT
*/
namespace BEAR\Package\Provide\Error;
use BEAR\Sunday\Extension\Router\RouterMatch as Request;
final class ExceptionAsString
{
* @var string
private $string;
public function __construct(\Exception $e, Request $request)
$eSummery = sprintf(
"%s(%s)\n in file %s on line %s\n\n%s",
\get_class($e),
$e->getMessage(),
$e->getFile(),
$e->getLine(),
$e->getTraceAsString()
);
$this->string = sprintf("%s\n%s\n\n%s\n%s\n\n", date(DATE_RFC2822), $request, $eSummery, $this->getPhpVariables($_SERVER));
}
public function __toString()
return $this->string;
private function getPhpVariables(array $server) : string
return sprintf("\nPHP Variables\n\n\$_SERVER => %s", print_r($server, true)); // @codeCoverageIgnore