kahlan\matcher\ToThrow::_matchException PHP Method

_matchException() public static method

Compares if two exception are similar.
public static _matchException ( object $actual, $exception ) : boolean
$actual object The actual instance.
return boolean
    public static function _matchException($actual, $exception)
    {
        if (!$actual) {
            return false;
        }
        if ($exception instanceof AnyException) {
            $code = $exception->getCode() ? $actual->getCode() : $exception->getCode();
            $class = get_class($actual);
        } else {
            $code = $actual->getCode();
            $class = get_class($exception);
        }
        if (get_class($actual) !== $class) {
            return false;
        }
        $sameCode = $code === $exception->getCode();
        $sameMessage = static::_sameMessage($actual->getMessage(), $exception->getMessage());
        return $sameCode && $sameMessage;
    }