/**
  * Check if data is valid
  *
  * @param AttributeInterface $attribute
  * @param mixed              $data
  */
 protected function checkData(AttributeInterface $attribute, $data)
 {
     if (null === $data) {
         return;
     }
     if (!is_string($data)) {
         throw InvalidArgumentException::stringExpected($attribute->getCode(), 'setter', 'simple select', gettype($data));
     }
 }
 /**
  * {@inheritdoc}
  */
 public function setValue(array $products, AttributeInterface $attribute, $data, $locale = null, $scope = null)
 {
     $this->checkLocaleAndScope($attribute, $locale, $scope, 'text');
     if (null !== $data && !is_string($data)) {
         throw InvalidArgumentException::stringExpected($attribute->getCode(), 'setter', 'text', gettype($data));
     }
     foreach ($products as $product) {
         $this->setData($attribute, $product, $data, $locale, $scope);
     }
 }
 /**
  * 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));
     }
 }
 /**
  * @param string $field
  * @param mixed  $value
  */
 protected function checkScalarValue($field, $value)
 {
     if (!is_string($value) && null !== $value) {
         throw InvalidArgumentException::stringExpected($field, 'filter', 'string', gettype($value));
     }
 }
 /**
  * @param AttributeInterface $attribute
  * @param mixed              $value
  */
 protected function checkValue(AttributeInterface $attribute, $value)
 {
     if (!is_string($value)) {
         throw InvalidArgumentException::stringExpected($attribute->getCode(), 'filter', 'media', gettype($value));
     }
 }
 /**
  * Check if data are valid
  *
  * @param string $field
  * @param mixed  $data
  */
 protected function checkData($field, $data)
 {
     if (!is_string($data) && null !== $data) {
         throw InvalidArgumentException::stringExpected($field, 'setter', 'variant_group', gettype($data));
     }
 }
 function it_throws_an_exception_if_value_is_not_valid($image)
 {
     $image->getCode()->willReturn('media_code');
     $value = ['data' => 132, 'unit' => 'foo'];
     $this->shouldThrow(InvalidArgumentException::stringExpected('media_code', 'filter', 'media', gettype($value)))->during('addAttributeFilter', [$image, '=', $value]);
 }
 function it_throws_an_error_if_data_is_not_a_string_or_null(AttributeInterface $attribute)
 {
     $attribute->getCode()->willReturn('attributeCode');
     $data = ['some', 'random', 'stuff'];
     $this->shouldThrow(InvalidArgumentException::stringExpected('attributeCode', 'setter', 'simple select', gettype($data)))->duringSetValue([], $attribute, $data, 'fr_FR', 'mobile');
 }
 /**
  * Check if value is valid
  *
  * @param string $field
  * @param mixed  $value
  */
 protected function checkValue($field, $value)
 {
     if (!is_string($value) && !is_array($value)) {
         throw InvalidArgumentException::stringExpected($field, 'filter', 'string', gettype($value));
     }
     if (is_array($value)) {
         foreach ($value as $stringValue) {
             if (!is_string($stringValue)) {
                 throw InvalidArgumentException::stringExpected($field, 'filter', 'string', gettype($value));
             }
         }
     }
 }
 function it_checks_valid_data_format(ProductInterface $product)
 {
     $this->shouldThrow(InvalidArgumentException::stringExpected('family', 'setter', 'family', 'array'))->during('setFieldData', [$product, 'family', ['not a string']]);
 }
 function it_throws_an_error_if_attribute_data_is_not_a_string_or_null(AttributeInterface $attribute, ProductInterface $product)
 {
     $attribute->getCode()->willReturn('attributeCode');
     $data = ['some', 'random', 'stuff'];
     $this->shouldThrow(InvalidArgumentException::stringExpected('attributeCode', 'setter', 'simple select', gettype($data)))->duringSetAttributeData($product, $attribute, $data, ['locale' => 'fr_FR', 'scope' => 'mobile']);
 }
 function it_throws_an_exception_if_value_is_not_a_string(AttributeInterface $attribute)
 {
     $attribute->getCode()->willReturn('attributeCode');
     $this->shouldThrow(InvalidArgumentException::stringExpected('attributeCode', 'filter', 'string', gettype(123)))->during('addAttributeFilter', [$attribute, '=', 123, null, null, ['field' => 'attributeCode']]);
 }
 function it_throws_an_error_if_data_is_not_a_string(AttributeInterface $attribute)
 {
     $attribute->getCode()->willReturn('attributeCode');
     $data = 42;
     $this->shouldThrow(InvalidArgumentException::stringExpected('attributeCode', 'setter', 'text', gettype($data)))->during('setValue', [[], $attribute, $data, 'fr_FR', 'mobile']);
 }