conversionFailedInvalidType() public static method

Thrown when the PHP value passed to the converter was not of the expected type.
public static conversionFailedInvalidType ( mixed $value, string $toType, array $possibleTypes ) : ConversionException
$value mixed
$toType string
$possibleTypes array
return ConversionException
Example #1
0
 /**
  * {@inheritdoc}
  */
 public function convertToDatabaseValue($value, AbstractPlatform $platform)
 {
     if (null === $value) {
         return $value;
     }
     if ($value instanceof \DateTime) {
         return $value->format($platform->getTimeFormatString());
     }
     throw ConversionException::conversionFailedInvalidType($value, $this->getName(), ['null', 'DateTime']);
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 public function convertToDatabaseValue($value, AbstractPlatform $platform)
 {
     if (null === $value) {
         return null;
     }
     if ($value instanceof \DateInterval) {
         return 'P' . str_pad($value->y, 4, '0', STR_PAD_LEFT) . '-' . $value->format('%M-%DT%H:%I:%S');
     }
     throw ConversionException::conversionFailedInvalidType($value, $this->getName(), ['null', 'DateInterval']);
 }