本文整理汇总了PHP中Pim\Bundle\CatalogBundle\Exception\InvalidArgumentException::arrayStringValueExpected方法的典型用法代码示例。如果您正苦于以下问题:PHP InvalidArgumentException::arrayStringValueExpected方法的具体用法?PHP InvalidArgumentException::arrayStringValueExpected怎么用?PHP InvalidArgumentException::arrayStringValueExpected使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pim\Bundle\CatalogBundle\Exception\InvalidArgumentException
的用法示例。
在下文中一共展示了InvalidArgumentException::arrayStringValueExpected方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkData
/**
* Check if data are valid
*
* @param string $field
* @param mixed $data
*/
protected function checkData($field, $data)
{
if (!is_array($data)) {
throw InvalidArgumentException::arrayExpected($field, 'remover', 'category', gettype($data));
}
foreach ($data as $key => $value) {
if (!is_string($value)) {
throw InvalidArgumentException::arrayStringValueExpected($field, $key, 'remover', 'category', gettype($value));
}
}
}
示例2: 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', 'multi select', gettype($data));
}
foreach ($data as $key => $value) {
if (!is_string($value)) {
throw InvalidArgumentException::arrayStringValueExpected($attribute->getCode(), $key, 'setter', 'multi select', gettype($value));
}
}
}
示例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_string($data['unit'])) {
throw InvalidArgumentException::arrayStringValueExpected($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']);
}
}
示例4:
function it_checks_valid_data_format(ProductInterface $product)
{
$this->shouldThrow(InvalidArgumentException::arrayExpected('categories', 'setter', 'category', 'string'))->during('setFieldData', [$product, 'categories', 'not an array']);
$this->shouldThrow(InvalidArgumentException::arrayStringValueExpected('categories', 0, 'setter', 'category', 'array'))->during('setFieldData', [$product, 'categories', [['array of array']]]);
}
示例5:
function it_throws_an_error_if_unit_from_attribute_data_is_not_a_string(AttributeInterface $attribute, ProductInterface $product)
{
$attribute->getCode()->willReturn('attributeCode');
$data = ['data' => 42, 'unit' => 123];
$this->shouldThrow(InvalidArgumentException::arrayStringValueExpected('attributeCode', 'unit', 'setter', 'metric', 123))->during('setAttributeData', [$product, $attribute, $data, ['locale' => 'fr_FR', 'scope' => 'mobile']]);
}
示例6:
function it_throws_an_error_if_attribute_data_is_not_an_array_of_option_codes(AttributeInterface $attribute, ProductInterface $product)
{
$attribute->getCode()->willReturn('attributeCode');
$data = ['foo' => ['bar' => 'baz']];
$this->shouldThrow(InvalidArgumentException::arrayStringValueExpected('attributeCode', 'foo', 'adder', 'multi select', 'array'))->during('addAttributeData', [$product, $attribute, $data, ['locale' => 'fr_FR', 'scope' => 'mobile']]);
}