當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。