soliantconsulting/SimpleFM

View on GitHub
src/Client/ResultSet/Exception/ParseException.php

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
<?php
declare(strict_types = 1);

namespace Soliant\SimpleFM\Client\ResultSet\Exception;

use DomainException;
use Exception;

final class ParseException extends DomainException implements ExceptionInterface
{
    public static function fromInvalidFieldType(string $name, string $type) : self
    {
        return new self(sprintf('Invalid field type "%s" for field "%s" discovered', $type, $name));
    }

    public static function fromConcreteException(
        string $database,
        string $table,
        string $layout,
        Exception $previousException
    ) : self {
        return new self(sprintf(
            'Could not parse response from database "%s" with table "%s" and layout "%s". Reason: %s',
            $database,
            $table,
            $layout,
            $previousException->getMessage()
        ), 0, $previousException);
    }
}