@param string $code
@param array  $attributeConfiguration

@throws \UnexpectedValueException

@return AttributeInterface
193606
public function createAttribute($code, array $attributeConfiguration = [])
    {
        $attributeClass = $this->attributeClass;
        /** @var AttributeInterface $attribute */
        $attribute = new $attributeClass(
            $code,
            $this->attributeTypeRegistry,
            $attributeConfiguration,
            $this->globalContextMask
        );
        if (method_exists($attribute, 'setTranslator')) {
            $attribute->setTranslator($this->translator);
        }

        return $attribute;
    }
1092078
public static function create($attribute, $value)
    {
        $attributesType = self::getAllAttributeType();
        foreach ($attributesType as $attributeType) {
            if ($attributeType->isMember($attribute)) {
                return $attributeType->create($value);
            }
        }

        return $value;
    }
934575
public function render(AttributeEvent $event)
    {
        $data = base64_decode($event->getValue());
        if (false === $data) {
           throw new \UnexpectedValueException('Error decoding data in the ' . $event->getAttribute() . ' attribute');
        }
        $event->setValue($data);
    }
308676
public function setIntegerValue($integerValue)
    {
        if (\is_array($integerValue) || \is_object($integerValue)) {
            $m = "Invalid value type for attribute {$this->getFamilyCode()}.{$this->getAttributeCode()}, ";
            $m .= 'expecting integer, got '.gettype($integerValue);
            throw new \UnexpectedValueException($m);
        }
        $this->integerValue = null === $integerValue ? null : (int) $integerValue;

        return $this;
    }
795204
public function setDecimalValue($decimalValue)
    {
        if (\is_array($decimalValue) || \is_object($decimalValue)) {
            $m = "Invalid value type for attribute {$this->getFamilyCode()}.{$this->getAttributeCode()}, ";
            $m .= 'expecting float, got '.gettype($decimalValue);
            throw new \UnexpectedValueException($m);
        }
        $this->decimalValue = null === $decimalValue ? null : (float) $decimalValue;

        return $this;
    }
1171852
public function getFamily(): FamilyInterface
    {
        $familyCode = $this->getConfiguration()->getOption('family');
        if (null === $familyCode) {
            throw new UnexpectedValueException(
                "Missing 'family' configuration option for {$this->getConfiguration()->getCode()}"
            );
        }

        return $this->familyRegistry->getFamily($familyCode);
    }
440888
public function build(): SetAttributeValueRequest
	{
		$instance = new SetAttributeValueRequest();
		if ($this->nodeId === null) {
			throw new BuilderException('Property [nodeId] is required.');
		}
		$instance->nodeId = $this->nodeId;
		if ($this->name === null) {
			throw new BuilderException('Property [name] is required.');
		}
		$instance->name = $this->name;
		if ($this->value === null) {
			throw new BuilderException('Property [value] is required.');
		}
		$instance->value = $this->value;
		return $instance;
	}
523253
private function initContextConfigurators()
    {
        $this->contextConfigurators = [];

        foreach ($this->loadContextConfigurators() as $configurator) {
            if (!$configurator instanceof ContextConfiguratorInterface) {
                throw new Exception\UnexpectedTypeException(
                    $configurator,
                    'Oro\Component\Layout\ContextConfiguratorInterface'
                );
            }

            $this->contextConfigurators[] = $configurator;
        }
    }
343529
public function replaceByAttribute($attributeKey, $attributeValue, array $params)
	{
		$params['key_attribute'] = $attributeKey;
		$params['key_value']     = $this->wrapAttributeValueWithQuotes($attributeValue);

		return $this->_replace($params);
	}
846535
public function getAction(string $code): Action
    {
        if (!$this->hasAction($code)) {
            throw new \UnexpectedValueException("No action with code: '{$code}' for admin '{$this->getCode()}'");
        }

        return $this->actions[$code];
    }
119478
public function addValue(AttributeValue $value)
    {
        $value->setAttribute($this);
        $this->values->add($value);

        return $this;
    }
260031
protected function validateConfig(string $name): self
    {
        if (array_key_exists($name, $this->config) === false) {
            throw new \UnexpectedValueException('No such configuration attribute: ' . $name);
        }
        return $this;
    }
169852
public function remove($attributeCode, $value, array $context = null)
    {
        $attribute = $this->getAttribute($attributeCode);

        $method = 'remove'.ucfirst($attributeCode);
        if (method_exists($this, $method)) {
            return $this->$method($value, $context);
        }

        return $this->removeValueData($attribute, $value, $context);
    }
111563
public function configureOptions(OptionsResolver $resolver)
    {
        parent::configureOptions($resolver);
        $resolver->setRequired(
            [
                'attribute',
            ]
        );
        $resolver->setAllowedTypes('attribute', ['string', AttributeInterface::class]);
        $resolver->setNormalizer(
            'attribute',
            function (Options $options, $value) {
                /** @var FamilyInterface $family */
                $family = $options['family'];
                if ($value instanceof AttributeInterface) {
                    if (!$family->hasAttribute($value->getCode())) {
                        throw new \UnexpectedValueException(
                            "Family {$family->getCode()} has no attribute named {$value->getCode()}"
                        );
                    }

                    return $value;
                }

                return $family->getAttribute($value);
            }
        );
    }
1219875
protected function writeOptionalAttribute(
        \XMLWriter $xmlWriter,
        $attributeName,
        $attributeValue
    ) {
        Validate::notNull($xmlWriter, 'xmlWriter');
        Validate::isString($attributeName, 'attributeName');

        if (!empty($attributeValue)) {
            $xmlWriter->writeAttribute(
                $attributeName,
                $attributeValue
            );
        }
    }
372355
protected function setInternalValuesData(AttributeInterface $attribute, $dataValues, array $context = null)
    {
        $this->checkAttribute($attribute);
        $dataValues = $this->ensureNativeArray($dataValues, $this->getFamilyCode().'.'.$attribute->getCode());
        $values = new ArrayCollection();
        $position = 0; // Reset position to zero

        foreach ($this->getInternalValues($attribute, $context) as $value) {
            // If there values to replace
            if (\count($dataValues)) {
                // Extract new values and replaces them one by one
                $dataValue = array_shift($dataValues);
                $value->setPosition(++$position);
                $this->setInternalValueData($attribute, $value, $dataValue);
                $values->add($value);
            } else {
                // If there are too much existing values previously, remove the extra ones
                $this->removeValue($value);
            }
        }

        // If there are still values to add
        foreach ($dataValues as $dataValue) {
            $value = $this->createValue($attribute, $context);
            $value->setPosition(++$position);
            $this->setInternalValueData($attribute, $value, $dataValue);
            $values->add($value);
        }

        return $values;
    }
261155
private Object getUnconfiguredAttributeValue(EvaluationContext context, ExtendedAttributeDefinition attributeDef) throws ConfigEvaluatorException {

        Object rawValue = null;

        // no value in config then try ibm:variable if set

        rawValue = variableEvaluator.lookupVariableExtension(context, attributeDef);

        // no value in config, no ibm:variable, try defaults
        if (rawValue == null) {
            String[] defaultValues = attributeDef.getDefaultValue();
            if (defaultValues != null) {
                rawValue = Arrays.asList(defaultValues);
            }
        }

        return rawValue;
    }