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


PHP InvalidArgumentException::arrayStringKeyExpected方法代码示例

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


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

示例1: checkData

 /**
  * Check if data is valid
  *
  * @param AttributeInterface $attribute
  * @param mixed              $data
  */
 protected function checkData(AttributeInterface $attribute, $data)
 {
     if (!is_array($data)) {
         throw InvalidArgumentException::arrayExpected($attribute->getCode(), 'setter', 'reference data collection', gettype($data));
     }
     foreach ($data as $key => $value) {
         if (!is_string($value)) {
             throw InvalidArgumentException::arrayStringKeyExpected($attribute->getCode(), $key, 'setter', 'reference data collection', gettype($value));
         }
     }
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:17,代码来源:ReferenceDataCollectionSetter.php

示例2:

 function it_throws_an_exception_if_value_is_not_an_valid_array(AttributeInterface $attribute)
 {
     $attribute->getCode()->willReturn('metric_code');
     $value = ['unit' => 'foo'];
     $this->shouldThrow(InvalidArgumentException::arrayKeyExpected('metric_code', 'data', 'filter', 'metric', print_r($value, true)))->during('addAttributeFilter', [$attribute, '=', $value]);
     $value = ['data' => 459];
     $this->shouldThrow(InvalidArgumentException::arrayKeyExpected('metric_code', 'unit', 'filter', 'metric', print_r($value, true)))->during('addAttributeFilter', [$attribute, '=', $value]);
     $value = ['data' => 'foo', 'unit' => 'foo'];
     $this->shouldThrow(InvalidArgumentException::arrayNumericKeyExpected('metric_code', 'data', 'filter', 'metric', 'string'))->during('addAttributeFilter', [$attribute, '=', $value]);
     $value = ['data' => 132, 'unit' => 42];
     $this->shouldThrow(InvalidArgumentException::arrayStringKeyExpected('metric_code', 'unit', 'filter', 'metric', 'integer'))->during('addAttributeFilter', [$attribute, '=', $value]);
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:12,代码来源:MetricFilterSpec.php

示例3: checkData

 /**
  * Check if data is valid
  *
  * @param AttributeInterface $attribute
  * @param mixed              $data
  */
 protected function checkData(AttributeInterface $attribute, $data)
 {
     if (!is_array($data)) {
         throw InvalidArgumentException::arrayExpected($attribute->getCode(), 'setter', 'metric', gettype($data));
     }
     if (!array_key_exists('data', $data)) {
         throw InvalidArgumentException::arrayKeyExpected($attribute->getCode(), 'data', 'setter', 'metric', print_r($data, true));
     }
     if (!array_key_exists('unit', $data)) {
         throw InvalidArgumentException::arrayKeyExpected($attribute->getCode(), 'unit', 'setter', 'metric', print_r($data, true));
     }
     if (!is_numeric($data['data']) && null !== $data['data']) {
         throw InvalidArgumentException::arrayNumericKeyExpected($attribute->getCode(), 'data', 'setter', 'metric', gettype($data['data']));
     }
     if (!is_string($data['unit'])) {
         throw InvalidArgumentException::arrayStringKeyExpected($attribute->getCode(), 'unit', 'setter', 'metric', $data['unit']);
     }
     if (!array_key_exists($data['unit'], $this->measureManager->getUnitSymbolsForFamily($attribute->getMetricFamily()))) {
         throw InvalidArgumentException::arrayInvalidKey($attribute->getCode(), 'unit', 'The unit does not exist', 'setter', 'metric', $data['unit']);
     }
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:27,代码来源:MetricValueSetter.php

示例4: checkValue

 /**
  * @param AttributeInterface $attribute
  * @param mixed              $data
  */
 protected function checkValue(AttributeInterface $attribute, $data)
 {
     if (!is_array($data)) {
         throw InvalidArgumentException::arrayExpected($attribute->getCode(), 'filter', 'price', gettype($data));
     }
     if (!array_key_exists('data', $data)) {
         throw InvalidArgumentException::arrayKeyExpected($attribute->getCode(), 'data', 'filter', 'price', print_r($data, true));
     }
     if (!array_key_exists('currency', $data)) {
         throw InvalidArgumentException::arrayKeyExpected($attribute->getCode(), 'currency', 'filter', 'price', print_r($data, true));
     }
     if (!is_numeric($data['data']) && null !== $data['data']) {
         throw InvalidArgumentException::arrayNumericKeyExpected($attribute->getCode(), 'data', 'filter', 'price', gettype($data['data']));
     }
     if (!is_string($data['currency'])) {
         throw InvalidArgumentException::arrayStringKeyExpected($attribute->getCode(), 'currency', 'filter', 'price', gettype($data['currency']));
     }
     if (!in_array($data['currency'], $this->currencyManager->getActiveCodes())) {
         throw InvalidArgumentException::arrayInvalidKey($attribute->getCode(), 'currency', 'The currency does not exist', 'filter', 'price', $data['currency']);
     }
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:25,代码来源:PriceFilter.php

示例5:

 function it_throws_an_error_if_data_is_not_an_array_of_option_codes(AttributeInterface $attribute)
 {
     $attribute->getCode()->willReturn('attributeCode');
     $data = ['foo' => ['bar' => 'baz']];
     $this->shouldThrow(InvalidArgumentException::arrayStringKeyExpected('attributeCode', 'foo', 'setter', 'multi select', 'array'))->during('setValue', [[], $attribute, $data, 'fr_FR', 'mobile']);
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:6,代码来源:MultiSelectValueSetterSpec.php

示例6:

 function it_throws_an_error_if_unit_is_not_a_string(AttributeInterface $attribute)
 {
     $attribute->getCode()->willReturn('attributeCode');
     $data = ['data' => 42, 'unit' => 123];
     $this->shouldThrow(InvalidArgumentException::arrayStringKeyExpected('attributeCode', 'unit', 'setter', 'metric', 123))->during('setValue', [[], $attribute, $data, 'fr_FR', 'mobile']);
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:6,代码来源:MetricValueSetterSpec.php


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