expressly/php-common

View on GitHub
src/Exception/ExceptionFormatter.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php

namespace Expressly\Exception;

class ExceptionFormatter
{
    public static function format(\Exception $exception)
    {
        if ($exception instanceof GenericException) {
            return (string)$exception;
        }

        return sprintf(
            '%s-%s (%s::%u)',
            get_class($exception),
            $exception->getMessage(),
            $exception->getFile(),
            $exception->getLine()
        );
    }
}