当前位置: 首页>>代码示例>>PHP>>正文


PHP ConversionException::conversionFailedFormat方法代码示例

本文整理汇总了PHP中Doctrine\DBAL\Types\ConversionException::conversionFailedFormat方法的典型用法代码示例。如果您正苦于以下问题:PHP ConversionException::conversionFailedFormat方法的具体用法?PHP ConversionException::conversionFailedFormat怎么用?PHP ConversionException::conversionFailedFormat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Doctrine\DBAL\Types\ConversionException的用法示例。


在下文中一共展示了ConversionException::conversionFailedFormat方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: convertToPHPValue

 /**
  * @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');
 }
开发者ID:zf2-boiler-app,项目名称:app-logger,代码行数:16,代码来源:RequestHeadersType.php

示例2: convertDateTimeString

 /**
  * @param string|DateTime $value
  * @param string          $fromFormat
  * @param string          $toFormat
  *
  * @return string
  *
  * @throws ConversionException
  *
  * @SuppressWarnings(PHPMD.StaticAccess)
  */
 private function convertDateTimeString($value, $fromFormat, $toFormat)
 {
     $dateTime = $value instanceof DateTime ? $value : DateTime::createFromFormat($fromFormat, $value);
     if ($dateTime === false) {
         throw ConversionException::conversionFailedFormat($value, $this->getName(), $fromFormat);
     }
     $result = $dateTime->format($toFormat);
     return $result;
 }
开发者ID:limoncello-php,项目名称:json-api,代码行数:20,代码来源:DateTimeDefaultStringType.php

示例3: convertToPHPValue

 /**
  * @override
  */
 public function convertToPHPValue($value, AbstractPlatform $platform)
 {
     if (null !== $value) {
         if (1 !== preg_match('/^\\d+$/', $value)) {
             throw ConversionException::conversionFailedFormat($value, $this->getName(), '^\\d+$');
         }
         $value = DateInterval::fromSeconds($value);
     }
     return $value;
 }
开发者ID:epoplive,项目名称:dateintervalbundle,代码行数:13,代码来源:DateIntervalType.php

示例4: convertToPHPValue

 /**
  * @override
  * @param mixed $value
  * @param AbstractPlatform $platform
  * @return mixed|DateRange
  * @throws ConversionException
  */
 public function convertToPHPValue($value, AbstractPlatform $platform)
 {
     if (null !== $value) {
         if (false == preg_match('/^(\\[|\\()(\\d{4})-(\\d{2})-(\\d{2}),(\\d{4})-(\\d{2})-(\\d{2})(\\]|\\))$/', $value)) {
             throw ConversionException::conversionFailedFormat($value, $this->getName(), '(\\[|\\()(\\d{4})-(\\d{2})-(\\d{2}),(\\d{4})-(\\d{2})-(\\d{2})(\\]|\\))$');
         }
         $value = DateRange::fromString($value);
     }
     return $value;
 }
开发者ID:salamek,项目名称:doctrine-daterange,代码行数:17,代码来源:DateRangeType.php

示例5: convertToDatabaseValue

 /**
  * {@inheritdoc}
  */
 public function convertToDatabaseValue($value, AbstractPlatform $platform)
 {
     if ($value === null) {
         return null;
     }
     if ($value instanceof Carbon) {
         return $value->copy()->setTimezone('UTC')->format($platform->getDateTimeFormatString());
     }
     throw ConversionException::conversionFailedFormat($value, $this->getName(), $platform->getDateTimeFormatString());
 }
开发者ID:Zn4rK,项目名称:laravel-template,代码行数:13,代码来源:CarbonType.php

示例6: convertToDatabaseValue

 /**
  * {@inheritdoc}
  */
 public function convertToDatabaseValue($value, AbstractPlatform $platform)
 {
     if (null === $value) {
         return $value;
     }
     if (!$value instanceof \DateTime) {
         throw ConversionException::conversionFailedFormat($value, $this->getName(), self::MICRO_FORMAT);
     }
     return $value->format(self::MICRO_FORMAT);
 }
开发者ID:p1x44r,项目名称:symfony-dbal-datetime-microsec,代码行数:13,代码来源:P1x44rSymfonyDbalDateTimeMicroSecType.php

示例7: convertToPHPValue

 /**
  * @see \Doctrine\DBAL\Types\Type::convertToPHPValue()
  * @param string|null $sValue
  * @param \Doctrine\DBAL\Platforms\AbstractPlatform $oPlatform
  * @return string|null
  */
 public function convertToPHPValue($sValue, \Doctrine\DBAL\Platforms\AbstractPlatform $oPlatform)
 {
     $sValue = parent::convertToPHPValue($sValue, $oPlatform);
     if (is_null($sValue)) {
         return $sValue;
     }
     if ($sFilterValue = filter_var($sValue, FILTER_VALIDATE_IP)) {
         return $sFilterValue;
     }
     throw \Doctrine\DBAL\Types\ConversionException::conversionFailedFormat($sValue, $this->getName(), 'valid IP adress');
 }
开发者ID:zf2-boiler-app,项目名称:app-logger,代码行数:17,代码来源:IPAdressType.php

示例8: convertToPHPValue

 /**
  * @param mixed $value
  * @param AbstractPlatform $platform
  * @return \DateTime|null
  * @throws ConversionException
  */
 public function convertToPHPValue($value, AbstractPlatform $platform)
 {
     if ($value === null) {
         return null;
     }
     $val = \DateTime::createFromFormat('!' . self::FORMAT, $value);
     if (empty($val)) {
         throw ConversionException::conversionFailedFormat($value, $this->getName(), self::FORMAT);
     }
     return $val;
 }
开发者ID:ramunasd,项目名称:doctrine-psql,代码行数:17,代码来源:TimeTzType.php

示例9: convertToPHPValue

 /**
  * @param \DateTimeImmutable|string|null $value
  * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform
  * @return \DateTimeImmutable|null
  */
 public function convertToPHPValue($value, AbstractPlatform $platform)
 {
     if ($value === null || $value instanceof DateTimeImmutable) {
         return $value;
     }
     $dateTime = DateTimeImmutable::createFromFormat('!' . $platform->getTimeFormatString(), $value);
     if ($dateTime === false) {
         throw \Doctrine\DBAL\Types\ConversionException::conversionFailedFormat($value, $this->getName(), $platform->getTimeFormatString());
     }
     return $dateTime;
 }
开发者ID:roelvanduijnhoven,项目名称:Doctrine-Date-Time-Immutable-Types,代码行数:16,代码来源:TimeImmutableType.php

示例10: convertToPHPValue

 /**
  * {@inheritDoc}
  */
 public function convertToPHPValue($value, AbstractPlatform $platform)
 {
     if ($value === null) {
         return null;
     }
     try {
         return Decimal::create($value);
     } catch (\Exception $e) {
         throw ConversionException::conversionFailedFormat($value, $this->getName(), '0.0');
     }
 }
开发者ID:coolms,项目名称:doctrine,代码行数:14,代码来源:DecimalObject.php

示例11: convertToPHPValue

 /**
  * {@inheritdoc}
  */
 public function convertToPHPValue($value, AbstractPlatform $platform)
 {
     if ($value === null || $value instanceof \DateInterval) {
         return $value;
     }
     try {
         return new \DateInterval($value);
     } catch (\Exception $exception) {
         throw ConversionException::conversionFailedFormat($value, $this->getName(), 'PY-m-dTH:i:s', $exception);
     }
 }
开发者ID:ismailbaskin,项目名称:dbal,代码行数:14,代码来源:DateIntervalType.php

示例12: convertToPHPValue

 /**
  * {@inheritdoc}
  */
 public function convertToPHPValue($value, AbstractPlatform $platform)
 {
     if (null === $value || $value instanceof \DateTime) {
         return $value;
     }
     $converted = \DateTime::createFromFormat($platform->getDateTimeFormatString(), $value, self::$utc ? self::$utc : (self::$utc = new \DateTimeZone('UTC')));
     if (!$converted) {
         throw ConversionException::conversionFailedFormat($value, $this->getName(), $platform->getDateTimeFormatString());
     }
     return $converted;
 }
开发者ID:tarlepp,项目名称:silex-backend,代码行数:14,代码来源:UTCDateTimeType.php

示例13: convertToPHPValue

 public function convertToPHPValue($value, AbstractPlatform $platform)
 {
     if ($value === null) {
         return null;
     }
     $val = DateTime::createFromFormat($platform->getDateTimeFormatString(), $value, $this->getUTCInstance());
     if ($val === false) {
         throw ConversionException::conversionFailedFormat($value, $this->getName(), $platform->getDateTimeFormatString());
     }
     return $val;
 }
开发者ID:tillikum,项目名称:tillikum-core-module,代码行数:11,代码来源:UTCDateTimeType.php

示例14: convertToPHPValue

 /**
  * {@inheritdoc}
  */
 public function convertToPHPValue($value, AbstractPlatform $platform)
 {
     if ($value === null || $value instanceof \DateTime) {
         return $value;
     }
     $val = \DateTime::createFromFormat('!' . $platform->getTimeFormatString(), $value);
     if (!$val) {
         throw ConversionException::conversionFailedFormat($value, $this->getName(), $platform->getTimeFormatString());
     }
     return $val;
 }
开发者ID:erikjwaxx,项目名称:dbal,代码行数:14,代码来源:TimeType.php

示例15: convertToPHPValue

 /**
  * @param string $dateTimeString
  * @param AbstractPlatform $platform
  *
  * @throws ConversionException
  *
  * @return DateTime|null
  */
 public function convertToPHPValue($dateTimeString, AbstractPlatform $platform)
 {
     if (null === $dateTimeString || $dateTimeString instanceof DateTime) {
         return $dateTimeString;
     }
     $dateTime = DateTime::createFromFormat($platform->getDateTimeFormatString(), $dateTimeString, self::getUtc());
     if (!$dateTime) {
         throw ConversionException::conversionFailedFormat($dateTimeString, $this->getName(), $platform->getDateTimeFormatString());
     }
     return $dateTime;
 }
开发者ID:forkcms,项目名称:forkcms,代码行数:19,代码来源:UTCDateTimeType.php


注:本文中的Doctrine\DBAL\Types\ConversionException::conversionFailedFormat方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。