conversionFailedInvalidType() 공개 정적인 메소드

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
리턴 ConversionException
예제 #1
0
파일: TimeType.php 프로젝트: erikjwaxx/dbal
 /**
  * {@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']);
 }
예제 #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']);
 }