本文整理汇总了PHP中Pim\Bundle\CatalogBundle\Exception\InvalidArgumentException::booleanExpected方法的典型用法代码示例。如果您正苦于以下问题:PHP InvalidArgumentException::booleanExpected方法的具体用法?PHP InvalidArgumentException::booleanExpected怎么用?PHP InvalidArgumentException::booleanExpected使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pim\Bundle\CatalogBundle\Exception\InvalidArgumentException
的用法示例。
在下文中一共展示了InvalidArgumentException::booleanExpected方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addFieldFilter
/**
* {@inheritdoc}
*/
public function addFieldFilter($field, $operator, $value, $locale = null, $scope = null, $options = [])
{
if (!is_bool($value)) {
throw InvalidArgumentException::booleanExpected($field, 'filter', 'boolean', gettype($value));
}
$field = sprintf('%s.%s', ProductQueryUtility::NORMALIZED_FIELD, FieldFilterHelper::getCode($field));
$this->qb->field($field)->equals($value);
return $this;
}
示例2: addFieldFilter
/**
* {@inheritdoc}
*/
public function addFieldFilter($field, $operator, $value, $locale = null, $scope = null, $options = [])
{
if (!is_bool($value)) {
throw InvalidArgumentException::booleanExpected($field, 'filter', 'boolean', gettype($value));
}
$field = current($this->qb->getRootAliases()) . '.' . FieldFilterHelper::getCode($field);
$condition = $this->prepareCriteriaCondition($field, $operator, $value);
$this->qb->andWhere($condition);
return $this;
}
示例3: checkData
/**
* Check if data are valid
*
* @param AttributeInterface $attribute
* @param mixed $data
*/
protected function checkData(AttributeInterface $attribute, $data)
{
if (!is_bool($data) && $data !== '0' && $data !== '1' && $data !== 0 && $data !== 1) {
throw InvalidArgumentException::booleanExpected($attribute->getCode(), 'setter', 'boolean', gettype($data));
}
}
示例4: gettype
function it_throws_an_error_if_data_is_not_a_boolean(AttributeInterface $attribute)
{
$attribute->getCode()->willReturn('attributeCode');
$data = 'not a boolean';
$this->shouldThrow(InvalidArgumentException::booleanExpected('attributeCode', 'setter', 'boolean', gettype($data)))->during('setValue', [[], $attribute, $data, 'fr_FR', 'mobile']);
}
示例5: gettype
function it_throws_an_exception_if_value_is_not_a_boolean()
{
$this->shouldThrow(InvalidArgumentException::booleanExpected('enabled', 'filter', 'boolean', gettype('not a boolean')))->during('addFieldFilter', ['enabled', '=', 'not a boolean']);
}