/**
  * {@inheritdoc}
  *
  * Expected data input format : "family_code"
  */
 public function setFieldData(ProductInterface $product, $field, $data, array $options = [])
 {
     $this->checkData($field, $data);
     if (null !== $data && '' !== $data) {
         $family = $this->getFamily($data);
         if (null === $family) {
             throw InvalidArgumentException::expected($field, 'existing family code', 'setter', 'family', $data);
         }
         $product->setFamily($family);
     } else {
         $product->setFamily(null);
     }
 }
 function it_empty_family_field($familyRepository, ProductInterface $product, FamilyInterface $shirt)
 {
     $product->setFamily(null)->shouldBeCalled();
     $this->setFieldData($product, 'family', null);
 }
 /**
  * Denormalize the product family
  *
  * @param string           $data
  * @param string           $format
  * @param array            $context
  * @param ProductInterface $product
  */
 protected function denormalizeFamily($data, $format, array $context, ProductInterface $product)
 {
     if (strlen($data) > 0) {
         $family = $this->serializer->denormalize($data, $this->familyClass, $format, $context);
     } else {
         $family = null;
     }
     $product->setFamily($family);
 }