Append a new value to a collection

@param string     $attributeCode
@param mixed      $value
@param array|null $context

@throws InvalidValueDataException
@throws MissingAttributeException
@throws ContextException

@return DataInterface
351244
public function add($attributeCode, $value, array $context = null)
    {
        $attribute = $this->getAttribute($attributeCode);

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

        return $this->addValueData($attribute, $value, $context);
    }
859813
public function addAttribute($attributeName, $value)
	{
		if(in_array($attributeName, $this->lockedAttributes) === true)
			throw new FormHandlerException('The attribute ' . $attributeName . ' is within the locked attributes for this renderer');
		
		$this->attributes[$attributeName] = $value;
	}
28214
public function append($value)
    {
        if ($this->isValidType($value) === false) {
            throw new MWrongTypeException("\$value", $this->getType(), $value);
        }

        $this->list[] = $value;
    }
544971
public static function execute($value, ContextInterface $context): array
    {
        // parser guarantees that input will be an array of [$type => $id] where type and id are scalars

        // we will check the type of every pair and send further identities only
        $indexes          = [];
        $foundInvalidType = null;
        $expectedType     = $context->getProperties()->getProperty(static::PROPERTY_RESOURCE_TYPE);
        foreach ($value as $typeAndId) {
            assert(is_array($typeAndId) === true && count($typeAndId) === 1);
            $index = reset($typeAndId);
            $type  = key($typeAndId);
            assert(is_scalar($index) === true && is_scalar($type) === true);
            if ($type === $expectedType) {
                $indexes[] = $index;
            } else {
                $foundInvalidType = $type;
                break;
            }
        }

        $reply = $foundInvalidType === null ?
            static::createSuccessReply($indexes) :
            static::createErrorReply(
                $context,
                $foundInvalidType,
                ErrorCodes::INVALID_RELATIONSHIP_TYPE,
                Messages::INVALID_RELATIONSHIP_TYPE,
                []
            );

        return $reply;
    }
578480
public static function addAttribute($attribute, $value, $options = [])
    {
        if (!isset(self::$instance)) {
            return;
        }
        return self::$instance->addAttribute($attribute, $value, $options);
    }
803235
public function add($value, array $attributes = null)
        {
            $cell = $value;
            if (is_string($value)) {
                $cell = new Cell($value, $attributes);
            }

            $this->_cells[] = $cell;

            return $this;
        }
1078009
public function addCustomData($key, $value)
    {
        if ($key == 'aps') {
            throw new \LogicException('Can\'t replace "aps" data. Please call to setMessage, if your want replace message text.');
        }

        if (is_object($value)) {
            if (interface_exists('JsonSerializable') && !$value instanceof \stdClass && !$value instanceof \JsonSerializable) {
                throw new \InvalidArgumentException(sprintf(
                    'Object %s::%s must be implements JsonSerializable interface for next serialize data.',
                    get_class($value), spl_object_hash($value)
                ));
            }
        }

        $this->customData[$key] = $value;

        return $this;
    }
1042327
protected function appendInternal($key, $value, $expiry = 0)
    {
        if ($this->hasInternal($key)) {
            $oldValue = $this->getInternal($key);
            if (!is_string($oldValue)) {
                throw new UnexpectedValueException(sprintf(
                    'Method append() requires existing value to be string, %s found.',
                    gettype($oldValue)
                ));
            }
            $value = $oldValue . $value;
        }
        return $this->setInternal($key, $value, $expiry);
    }
614621
public static function encode($value, Context $context)
    {
        if (is_bool($value)) {
            return new BooleanValue($context->getIsolate(), $value);
        } elseif (is_string($value)) {
            return new StringValue($context->getIsolate(), $value);
        } elseif (is_float($value)) {
            return new NumberValue($context->getIsolate(), $value);
        } elseif (is_int($value)) {
            return new IntegerValue($context->getIsolate(), $value);
        } elseif ($value === null) {
            return new NullValue($context->getIsolate());
        } elseif ($value instanceof \DateTime) {
            return new DateObject($context, $value->getTimestamp() * 1000);
        } elseif ($value instanceof ObjectInterface) {
            return self::encode($value->getProperties(), $context);
        } elseif ($value instanceof \Closure || is_callable($value)) {
            return new FunctionObject($context, function(FunctionCallbackInfo $info) use ($value){
                $args   = $info->arguments();
                $params = [];
                foreach ($args as $arg) {
                    $params[] = Decoder::decode($arg, $info->getContext());
                }

                $return = call_user_func_array($value, $params);

                $info->getReturnValue()->set(self::encode($return, $info->getContext()));
            });
        } elseif ($value instanceof \ArrayObject) {
            return self::encode($value->getArrayCopy(), $context);
        } elseif ($value instanceof \Traversable) {
            return self::encode(iterator_to_array($value), $context);
        } elseif ($value instanceof \JsonSerializable) {
            return self::encode($value->jsonSerialize(), $context);
        } elseif ($value instanceof \stdClass || (is_array($value) && self::isAssoc($value))) {
            $object = new ObjectValue($context);
            foreach ($value as $key => $val) {
                $object->set(
                    $context,
                    self::encode($key, $context),
                    self::encode($val, $context)
                );
            }
            return $object;
        } elseif (is_array($value)) {
            $array = new ArrayObject($context);
            $index = 0;
            foreach ($value as $val) {
                $array->set(
                    $context,
                    self::encode($index, $context),
                    self::encode($val, $context)
                );
                $index++;
            }
            return $array;
        } elseif (is_object($value) && method_exists($value, '__toString')) {
            return new StringValue($context->getIsolate(), $value->__toString());
        } else {
            return new NullValue($context->getIsolate());
        }
    }
394123
private function prepareSimpleIndexAttributeValue(AttributeInterface $attribute, $value)
    {
        if ($this->getFieldType($attribute) == FieldInterface::FIELD_TYPE_BOOLEAN) {
            $value = boolval($value);
        } elseif ($attribute->getBackendType() == 'decimal') {
            $value = floatval($value);
        } elseif ($attribute->getBackendType() == 'int') {
            $value = intval($value);
        }

        return $value;
    }
231927
public static function instantiate(AttributeContract $attribute, $value)
    {
        if (! $attribute->supportsValues()) {
            throw new AttributeMustSupportValues();
        }

        return new static([
            'attribute_id' => $attribute->id,
            'value' => $value,
        ]);
    }
959173
public function appendFormattedElement(XMLElement &$wrapper, $data, $encode = false, $mode = null, $entry_id = null)
    {
        // It is possible an array of null data will be passed in. Check for this.
        if (!is_array($data) || !isset($data['file']) || is_null($data['file'])) {
            return;
        }

        $file = $this->getFilePath($data['file']);
        $filesize = (file_exists($file) && is_readable($file)) ? filesize($file) : null;
        $item = new XMLElement($this->get('element_name'));
        $item->setAttributeArray(array(
            'size' =>   !is_null($filesize) ? General::formatFilesize($filesize) : 'unknown',
            'bytes' =>  !is_null($filesize) ? $filesize : 'unknown',
            'path' =>   General::sanitize(
                str_replace(WORKSPACE, null, dirname($file))
            ),
            'type' =>   $data['mimetype']
        ));

        $item->appendChild(new XMLElement('filename', General::sanitize(basename($file))));

        $m = unserialize($data['meta']);

        if (is_array($m) && !empty($m)) {
            $item->appendChild(new XMLElement('meta', null, $m));
        }

        $wrapper->appendChild($item);
    }
293661
public function addAttribute($attribute, $value)
    {
        $value = is_array($value) ? $value : [$value];

        if (!isset($this->attributes[$attribute])) {
            $this->attributes[$attribute] = [];
        }
        foreach ($value as $attrValue) {
            $this->attributes[$attribute][] = $attrValue;
        }

        return $this;
    }
833303
public function addAttribute($attributeName, $attributeType)
    {
        if (empty($attributeName) || empty($attributeType)) {
            throw new \InvalidArgumentException(sprintf('Attribute name "%s" and/or attribute type "%s" is invalid for Struct "%s"', $attributeName, $attributeType, $this->getName()), __LINE__);
        }
        if ($this->attributes->getStructAttributeByName($attributeName) === null) {
            $structAttribute = new StructAttribute($this->getGenerator(), $attributeName, $attributeType, $this);
            $this->attributes->add($structAttribute);
        }
        return $this;
    }
582789
protected function _appendDataToNode($addCdata, Xml $xml, $key, $value)
    {
        if ($addCdata) {
            $cdata      = $xml->createCDATASection($value);
            $element    = $xml->createElement(
                $this->_integerToStringKey($key)
            );
            $element->appendChild($cdata);
        } else {
            $element = $xml->createElement(
                $this->_integerToStringKey($key),
                $value
            );
        }

        return $element;
    }
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;
    }
462079
private function updateData(array $data, string $attribute, $attributeValue, string $class, ?string $format, array $context): array
    {
        if (null === $attributeValue && ($context[self::SKIP_NULL_VALUES] ?? $this->defaultContext[self::SKIP_NULL_VALUES] ?? false)) {
            return $data;
        }

        if ($this->nameConverter) {
            $attribute = $this->nameConverter->normalize($attribute, $class, $format, $context);
        }

        $data[$attribute] = $attributeValue;

        return $data;
    }