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