Doctrine\DBAL\Types\ConversionException::conversionFailedFormat PHP Method

conversionFailedFormat() public static method

Thrown when a Database to Doctrine Type Conversion fails and we can make a statement about the expected format.
public static conversionFailedFormat ( string $value, string $toType, string $expectedFormat, Exception $previous = null ) : ConversionException
$value string
$toType string
$expectedFormat string
$previous Exception
return ConversionException
    public static function conversionFailedFormat($value, $toType, $expectedFormat, \Exception $previous = null)
    {
        $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, 0, $previous);
    }

Usage Example

 /**
  * @see \Doctrine\DBAL\Types\JsonArrayType::convertToPHPValue()
  * @param string $sValue
  * @param \Doctrine\DBAL\Platforms\AbstractPlatform $oPlatform
  * @throws \Doctrine\DBAL\Types\ConversionException
  * @return \Zend\Http\Headers
  */
 public function convertToPHPValue($sValue, \Doctrine\DBAL\Platforms\AbstractPlatform $oPlatform)
 {
     $aValue = parent::convertToPHPValue($sValue, $oPlatform);
     if (is_array($aValue)) {
         $oHeaders = new \Zend\Http\Headers();
         return $oHeaders->addHeaders($aValue);
     }
     throw \Doctrine\DBAL\Types\ConversionException::conversionFailedFormat($sValue, $this->getName(), 'json encoded array');
 }
All Usage Examples Of Doctrine\DBAL\Types\ConversionException::conversionFailedFormat