. */ /** * Conversion Exception is thrown when the database to PHP conversion fails * * @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @link www.doctrine-project.com * @since 2.0 * @author Benjamin Eberlei * @author Guilherme Blanco * @author Jonathan Wage * @author Roman Borschel */ namespace Doctrine\DBAL\Types; class ConversionException extends \Doctrine\DBAL\DBALException { /** * Thrown when a Database to Doctrine Type Conversion fails. * * @param string $value * @param string $toType * @return ConversionException */ static public function conversionFailed($value, $toType) { $value = (strlen($value) > 32) ? substr($value, 0, 20) . "..." : $value; return new self('Could not convert database value "' . $value . '" to Doctrine Type ' . $toType); } /** * Thrown when a Database to Doctrine Type Conversion fails and we can make a statement * about the expected format. * * @param string $value * @param string $toType * @return ConversionException */ static public function conversionFailedFormat($value, $toType, $expectedFormat) { $value = (strlen($value) > 32) ? substr($value, 0, 20) . "..." : $value; return new self( 'Could not convert database value "' . $value . '" to Doctrine Type ' . $toType . '. Expected format: ' . $expectedFormat ); } }