Creates a ValueHolderInterface, that is specific to the current attribute instance.

@return ValueHolderInterface
505946
public function createValueHolder($apply_default_values = false)
    {
        if (!$this->value_holder_implementor) {
            $implementor = $this->hasOption(self::OPTION_VALUE_HOLDER)
                ? $this->getOption(self::OPTION_VALUE_HOLDER)
                : $this->buildDefaultValueHolderClassName();

            if (!class_exists($implementor)) {
                throw new InvalidConfigException(
                    sprintf(
                        "Invalid valueholder implementor '%s' configured for attribute '%s' on entity '%s'.",
                        $implementor,
                        $this->getName(),
                        $this->getType() ? $this->getType()->getName() : 'undefined'
                    )
                );
            }

            $test_value_holder = new $implementor($this);

            if (!$test_value_holder instanceof ValueHolderInterface) {
                throw new InvalidTypeException(
                    sprintf(
                        "Invalid valueholder implementation '%s' given for attribute '%s' on entity type '%s'. " .
                        "Make sure to implement '%s'.",
                        $implementor,
                        $this->getName(),
                        $this->getType() ? $this->getType()->getName() : 'undefined',
                        ValueHolderInterface::CLASS
                    )
                );
            }

            $this->value_holder_implementor = $implementor;
        }

        $value_holder = new $this->value_holder_implementor($this);
        if ($apply_default_values === true) {
            $value_holder->setValue($this->getDefaultValue());
        } elseif ($apply_default_values === false) {
            $value_holder->setValue($this->getNullValue());
        } else {
            throw new InvalidTypeException(
                sprintf(
                    "Only boolean arguments are acceptable for attribute '%s' on entity type '%s'. ",
                    $this->getName(),
                    $this->getType() ? $this->getType()->getName() : 'undefined'
                )
            );
        }

        return $value_holder;
    }
810032
public function asObjectIdentifier(): Primitive\ObjectIdentifier
    {
        if (!$this->_element instanceof Primitive\ObjectIdentifier) {
            throw new \UnexpectedValueException(
                $this->_generateExceptionMessage(
                    Element::TYPE_OBJECT_IDENTIFIER));
        }
        return $this->_element;
    }
1217537
public function getDefaultValue()
    {
        $default = $this->_default;

        if ($default && !$this->isScalar()) {
            $default = $default instanceof AnDomainAttributeInterface ? clone $default :
                        AnDomainAttribute::getInstance($this->_type);
        }

        return $default;
    }
125400
protected function createDefaultValues(AttributeInterface $attribute, array $context = null)
    {
        $default = $attribute->getDefault();
        if (!$attribute->isCollection()) {
            $default = (array) $default;
        }

        return $this->setInternalValuesData($attribute, $default, $context);
    }
611343
protected function placeholderResolver()
    {
        if (null === $this->placeholderResolver) {
            $this->placeholderResolver = new RegexPlaceholderResolver(new ConfigurationDataSource($this), '%', '%');
        }

        return $this->placeholderResolver;
    }
1053394
public function asObjectDescriptor(): Primitive\ObjectDescriptor
    {
        if (!$this->_element instanceof Primitive\ObjectDescriptor) {
            throw new \UnexpectedValueException(
                $this->_generateExceptionMessage(
                    Element::TYPE_OBJECT_DESCRIPTOR));
        }
        return $this->_element;
    }
597612
public function relatedMetaInformation(): KeyValueCollectionInterface
    {
        if (!$this->relatedMetaInformation instanceof KeyValueCollectionInterface) {
            $this->relatedMetaInformation = new KeyValueCollection();
        }

        return $this->relatedMetaInformation;
    }
136274
public function getValue() {
        $type = (string) $this->element->attributes()->type;
        $type = (empty($type)) ? 'string' : $type;
        $value = (string) $this->element->attributes()->value;

        $casterClassName = $this->resolveCasterClassName($type);

        /** @type \BuildR\TestTools\Caster\CasterInterface $casterObject */
        $casterObject = new $casterClassName($value);
        return $casterObject->cast();
    }
770722
public function transform(Value\ValueInterface $value)
    {
        return $this->placeholderUnwrap()->transform(parent::transform($value));
    }
413657
protected function createValueHolderChangedEvent($prev_value, EventInterface $embedded_event = null)
    {
        return new ValueChangedEvent(
            array(
                'attribute_name' => $this->getAttribute()->getName(),
                'prev_value' => $prev_value,
                'value' => $this->toNative(),
                'embedded_event' => $embedded_event
            )
        );
    }
801154
public function removeValue(ValueInterface $value)
    {
        $this->values->removeElement($value);
        $value->setData(null);

        $this->removeValueByAttribute($value);

        return $this;
    }
396832
protected function attributeValue() {
        if ($this->scanner->current() != '=') {
            return null;
        }
        $this->scanner->next();
        // 8.1.2.3
        $this->scanner->whitespace();

        $tok = $this->scanner->current();
        switch ($tok) {
            case "\n":
            case "\f":
            case " ":
            case "\t":
                // Whitespace here indicates an empty value.
                return null;
            case '"':
            case "'":
                $this->scanner->next();
                return $this->quotedAttributeValue($tok);
            case '>':
                // case '/': // 8.2.4.37 seems to allow foo=/ as a valid attr.
                $this->parseError("Expected attribute value, got tag end.");
                return null;
            case '=':
            case '`':
                $this->parseError("Expecting quotes, got %s.", $tok);
                return $this->unquotedAttributeValue();
            default:
                return $this->unquotedAttributeValue();
        }
    }
476038
public function getCreator()
    {
        return $this->getCachedProperty(
            'creator',
            function () {
                try {
                    return $this->getValue('creator')
                        ? new Account($this->getValue('creator'))
                        : null;
                } catch (\InvalidArgumentException $e) {
                    throw new \UnexpectedValueException($e->getMessage(), $e->getCode(), $e);
                }
            }
        );
    }
236899
public function createAttributeValueFromRequest()
    {
        $data = $this->post();
        if (!is_array($data)) {
            $data = [];
        }
        $data += [
            'operation' => null,
            'current-token' => '',
            'current-token-hash' => '',
        ];
        switch ($data['operation']) {
            case 'keep':
                $value = $data['current-token'];
                if (!is_string($value)) {
                    $value = '';
                }
                if ($value !== '') {
                    if (sha1($this->getSessionHash(false) . $value) !== $data['current-token-hash']) {
                        $ok = false;
                    } else {
                        $ok = $this->app->make(Token::class)->isGenerated($value);
                    }
                    if (!$ok) {
                        throw new Exception('Hack attempt detected.');
                    }
                }
                break;
            case 'generate':
                $value = $this->app->make(Token::class)->generate();
                break;
            case 'remove':
                $value = '';
                break;
            default:
                throw new Exception('Invalid operation');
        }

        return $this->createAttributeValue($value);
    }
462473
public function getTemplate()
    {
        if (!$this->__template instanceof TemplateInterface)
        {
            //Make sure we have a template identifier
            if (!($this->__template instanceof ObjectIdentifier)) {
                $this->setTemplate($this->__template);
            }

            $options = array(
                'filters'   => $this->getConfig()->template_filters,
                'functions' => $this->getConfig()->template_functions,
            );

            $this->__template = $this->getObject($this->__template, $options);

            if(!$this->__template instanceof TemplateInterface)
            {
                throw new \UnexpectedValueException(
                    'Template: '.get_class($this->__template).' does not implement TemplateInterface'
                );
            }
        }

        return $this->__template;
    }
978275
public function getDefaultOwnerAttributeValue()
    {
        if (Yii::$app->has('user')) {
            $userId = Yii::$app->get('user')->id;
            if ($userId === null) { // something wrong
                throw new InvalidValueException('Empty owner ID');
            }
            return $userId;
        }
    }
327095
public function map(ValueObject $value): RoleCreateData
    {
        if (!$value instanceof RoleCreateStruct) {
            throw new InvalidArgumentException('value', 'must be an instance of ' . RoleCreateStruct::class);
        }

        $data = new RoleCreateData();

        $data->setIdentifier($value->identifier);

        return $data;
    }