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


PHP InvalidArgumentException::numericExpected方法代码示例

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


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

示例1: checkValue

 /**
  * {@inheritdoc}
  */
 protected function checkValue($field, $value, $locale, $scope)
 {
     if (!is_numeric($value)) {
         throw InvalidArgumentException::numericExpected($field, 'filter', 'completeness', gettype($value));
     }
     if (null === $scope) {
         throw new InvalidArgumentException('Scope expected for completeness filter. None given.');
     }
 }
开发者ID:techpub,项目名称:EnhancedConnectorBundle,代码行数:12,代码来源:CompletenessFilter.php

示例2: checkValue

 /**
  * Check if value is valid
  *
  * @param string      $field
  * @param mixed       $value
  * @param string|null $locale
  * @param string|null $scope
  */
 protected function checkValue($field, $value, $locale, $scope)
 {
     if (!is_numeric($value)) {
         throw InvalidArgumentException::numericExpected($field, 'filter', 'completeness', gettype($value));
     }
     if (null === $locale || null === $scope) {
         throw InvalidArgumentException::localeAndScopeExpected($field, 'filter', 'completeness');
     }
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:17,代码来源:CompletenessFilter.php

示例3: addAttributeFilter

 /**
  * {@inheritdoc}
  */
 public function addAttributeFilter(AttributeInterface $attribute, $operator, $value, $locale = null, $scope = null, $options = [])
 {
     $this->checkLocaleAndScope($attribute, $locale, $scope, 'number');
     if (!is_numeric($value) && null !== $value) {
         throw InvalidArgumentException::numericExpected($attribute->getCode(), 'filter', 'number', gettype($value));
     }
     $field = ProductQueryUtility::getNormalizedValueFieldFromAttribute($attribute, $locale, $scope);
     $field = sprintf('%s.%s', ProductQueryUtility::NORMALIZED_FIELD, $field);
     $this->applyFilter($operator, $value, $field);
     return $this;
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:14,代码来源:NumberFilter.php

示例4: checkIdentifier

 /**
  * Check if value is a valid identifier
  *
  * @param string $field
  * @param mixed  $value
  * @param string $filter
  */
 public static function checkIdentifier($field, $value, $filter)
 {
     $invalidIdField = static::hasProperty($field) && static::getProperty($field) === 'id' && !is_numeric($value);
     $invalidDefaultField = !static::hasProperty($field) && !is_numeric($value);
     if ($invalidIdField || $invalidDefaultField) {
         throw InvalidArgumentException::numericExpected(static::getCode($field), 'filter', $filter, gettype($value));
     }
     $invalidStringField = static::hasProperty($field) && static::getProperty($field) !== 'id' && !is_string($value);
     if ($invalidStringField) {
         throw InvalidArgumentException::stringExpected(static::getCode($field), 'filter', $filter, gettype($value));
     }
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:19,代码来源:FieldFilterHelper.php

示例5: setValue

 /**
  * {@inheritdoc}
  */
 public function setValue(array $products, AttributeInterface $attribute, $data, $locale = null, $scope = null)
 {
     if (null === $this->productBuilder) {
         throw new \RuntimeException('The product builder should be set.');
     }
     $this->checkLocaleAndScope($attribute, $locale, $scope, 'number');
     if (!is_numeric($data) && null !== $data) {
         throw InvalidArgumentException::numericExpected($attribute->getCode(), 'setter', 'number', gettype($data));
     }
     foreach ($products as $product) {
         $this->setData($attribute, $product, $data, $locale, $scope);
     }
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:16,代码来源:NumberValueSetter.php

示例6: addAttributeFilter

 /**
  * {@inheritdoc}
  */
 public function addAttributeFilter(AttributeInterface $attribute, $operator, $value, $locale = null, $scope = null, $options = [])
 {
     $this->checkLocaleAndScope($attribute, $locale, $scope, 'number');
     if (!is_numeric($value) && null !== $value) {
         throw InvalidArgumentException::numericExpected($attribute->getCode(), 'filter', 'number', gettype($value));
     }
     $joinAlias = $this->getUniqueAlias('filter' . $attribute->getCode());
     $backendField = sprintf('%s.%s', $joinAlias, $attribute->getBackendType());
     if ($operator === Operators::IS_EMPTY) {
         $this->qb->leftJoin($this->qb->getRootAlias() . '.values', $joinAlias, 'WITH', $this->prepareAttributeJoinCondition($attribute, $joinAlias, $locale, $scope));
         $this->qb->andWhere($this->prepareCriteriaCondition($backendField, $operator, $value));
     } else {
         $condition = $this->prepareAttributeJoinCondition($attribute, $joinAlias, $locale, $scope);
         $condition .= ' AND ' . $this->prepareCriteriaCondition($backendField, $operator, $value);
         $this->qb->innerJoin($this->qb->getRootAlias() . '.values', $joinAlias, 'WITH', $condition);
     }
     return $this;
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:21,代码来源:NumberFilter.php

示例7: gettype

 function it_throws_an_exception_if_the_content_of_value_are_not_numeric(AttributeInterface $attribute)
 {
     $attribute->getCode()->willReturn('options_code');
     $this->shouldThrow(InvalidArgumentException::numericExpected('options_code', 'filter', 'options', gettype('WRONG')))->during('addAttributeFilter', [$attribute, 'IN', [123, 'not numeric'], null, null, ['field' => 'options_code.id']]);
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:5,代码来源:OptionsFilterSpec.php

示例8:

 function it_throws_an_exception_if_value_is_not_a_valid_array(AttributeInterface $attribute)
 {
     $attribute->getId()->willReturn(1);
     $attribute->getCode()->willReturn('color');
     $value = 'string';
     $this->shouldThrow(InvalidArgumentException::arrayExpected('color', 'filter', 'reference_data', $value))->during('addAttributeFilter', [$attribute, '=', $value, null, null, ['field' => 'color']]);
     $value = ['foo'];
     $this->shouldThrow(InvalidArgumentException::numericExpected('color', 'filter', 'reference_data', 'string'))->during('addAttributeFilter', [$attribute, '=', $value, null, null, ['field' => 'color']]);
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:9,代码来源:ReferenceDataFilterSpec.php

示例9: gettype

 function it_throws_an_exception_if_value_is_not_an_integer()
 {
     $this->shouldThrow(InvalidArgumentException::numericExpected('completeness', 'filter', 'completeness', gettype('123')))->during('addFieldFilter', ['completeness', '=', '12a3', 'fr_FR', 'mobile']);
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:4,代码来源:CompletenessFilterSpec.php

示例10: gettype

 function it_throws_an_exception_if_content_of_array_is_not_integer_or_empty()
 {
     $this->shouldThrow(InvalidArgumentException::numericExpected('family', 'filter', 'family', gettype('WRONG')))->during('addFieldFilter', ['family', 'IN', [1, 2, 'WRONG']]);
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:4,代码来源:FamilyFilterSpec.php

示例11: gettype

 function it_throws_an_error_if_data_is_not_a_number_or_null(AttributeInterface $attribute)
 {
     $attribute->getCode()->willReturn('attributeCode');
     $data = 'not a number';
     $this->shouldThrow(InvalidArgumentException::numericExpected('attributeCode', 'setter', 'number', gettype($data)))->during('setValue', [[], $attribute, $data, 'fr_FR', 'mobile']);
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:6,代码来源:NumberValueSetterSpec.php

示例12: gettype

 function it_throws_an_exception_if_value_is_not_a_numeric(AttributeInterface $attribute)
 {
     $attribute->getCode()->willReturn('number_code');
     $this->shouldThrow(InvalidArgumentException::numericExpected('number_code', 'filter', 'number', gettype('WRONG')))->during('addAttributeFilter', [$attribute, '=', 'WRONG']);
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:5,代码来源:NumberFilterSpec.php


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