adds OptionType to product.

@param OptionType $optionType

@throws InvalidArgumentException
343315
public function addOptionType(OptionType $optionType): void
    {
        if ($this->optionTypes->contains($optionType)) {
            throw new InvalidArgumentException(sprintf('OptionType « %s » for product « %s » is already set', $optionType->getName(), $this->getName()));
        }
        $this->optionTypes->add($optionType);
        $optionType->addProduct($this);
    }
1361707
def add(self, option):
				
		if option.__class__ == Option:
			for _option in self.options:
				if option.name == _option.name:
					raise OptionDuplicateError(_option.name)
			self.options.append(option)
		else:
			raise TypeError("invalid type supplied")
1114527
private function addProductOption(ProductOptionInterface $option, $value, $code)
    {
        /** @var ProductOptionValueInterface $optionValue */
        $optionValue = $this->productOptionValueFactory->createNew();

        $optionValue->setValue($value);
        $optionValue->setCode($code);
        $optionValue->setOption($option);

        $option->addValue($optionValue);

        return $optionValue;
    }
21595
public function addOption( $opt, $type ) {
        if( $type !== self::OPT_PARAM || $type !== self::OPT_SWITCH ) {
            return;
        }
        
        $this->options[(string)$opt] = $type;
    }
677408
protected function buildSelect($fieldType)
    {
        $this->children[] = new $fieldType(
            $this->name,
            $this->choiceType,
            $this->parent,
            $this->formHelper->mergeOptions($this->options, ['is_child' => true])
        );
    }
260069
public function addCustomType($type)
    {
        if (!Type::hasType($type)) {
            throw TypeException::typeDoesNotExist($type);
        }

        if ($this->hasCustomType($type)) {
            throw PlatformException::customTypeAlreadyExists($type);
        }

        $this->customTypes[] = $type;
    }
190695
public function setProductType(string $type)
    {
        $types = [self::TYPE_DIGITAL, self::TYPE_PHYSICAL, self::TYPE_HYBRID];

        if (!in_array($type, $types)) {
            throw new \InvalidArgumentException('Invalid productType \'' . $type . '\'');
        }
        $this->productType = $type;
    }
73269
public function setDoctype($doctype)
    {
        if (!array_key_exists($doctype, $this->doctypes)) {
            throw new \InvalidArgumentException(sprintf('Invalid Doctype "%s"', $doctype));
        }

        $this->doctype = $doctype;
    }
1140810
public function setType($type)
    {
        if (is_string($type) && in_array($type, self::$types)) {
            $this->type = $type;
        } else {
            throw new InvalidArgumentException;
        }
    }
983723
public function setType($type)
    {
        if (is_string($type) === true) {
            $this->type = $type;
        } else {
            $msg = "The 'type' argument must be a non-empty string representing a mime-type, '" . gettype($type) . "' given.";
            throw new InvalidArgumentException($msg);
        }
    }
71482
public function setType($type = null)
    {
        $type = $this->calculateTypeValue($type);

        if (!is_int($type) || ($type < 0) || ($type > self::ALL)) {
            throw new Exception\InvalidArgumentException('Unknown type');
        }

        $this->options['type'] = $type;

        return $this;
    }
879081
public function setPropertyType($type)
    {
        if (empty($type)) {
            $this->propertyType = null;
            return $this;
        }

        if (!is_string($type)) {
            throw new InvalidArgumentException(
                'Property type must be a string'
            );
        }

        $this->propertyType = $type;

        return $this;
    }
1168942
public function setOutputTypeOptions($input_type, OutputTypeOptionsInterface $options)
    {
        $this->map[$input_type] = $options;
        $this->types = array_keys($this->map);
        return $this;
    }
201024
public function setPaymentType($paymentType)
    {
        $allowedPaymentTypes = [
            self::PAYMENT_TYPE_ONLINE_BANKING, self::PAYMENT_TYPE_QR_PAYMENT, self::PAYMENT_TYPE_QUICK_PAYMENT
        ];

        if (in_array($paymentType, $allowedPaymentTypes)) {
            $this->payment_type = $paymentType;

            return $this;
        }

        throw new InvalidArgument(
            'Invalid value for payment_type. Allowed values are ' . implode(', ', $allowedPaymentTypes)
        );
    }
128231
public function setType($type)
    {
        if (!array_key_exists($type, self::$Supported)) {
            throw new \InvalidArgumentException(sprintf(
                    'Invalid Sharpen Type "%s"', $type
            ));
        }
        $this->type = $type;
    }
763521
public function setModelType($modelType)
    {
        if ($modelType < self::MODELTYPE_ENTITY || $modelType > self::MODELTYPE_VALUEOBJECT) {
            throw new \InvalidArgumentException('"' . $modelType . '" is an invalid model type.', 1212519195);
        }
        $this->modelType = $modelType;
    }
1329038
private function isValidCodeType(string $codeType): void
    {
        $allowedCodeType = $this->getAllowedCodeType();
        if (!\in_array($codeType, $allowedCodeType, true)) {
            throw new InvalidTypeException(sprintf(
                'codeType must be either "%s".',
                implode(', ', $allowedCodeType)
            ));
        }
    }