Attaches the value.

@param mixed       $value   The value
@param null|string $capture Optional; any of the capture type constants

@throws \InvalidArgumentException If invalid capture type provided

@return self
355565
public function attach($value, $capture = null)
    {
        if (null === $capture) {
            $capture = $this->captureType;
        }

        switch ($capture) {
            case self::APPEND:
                $this->append($value);
                break;
            case self::PREPEND:
                $this->prepend($value);
                break;
            case self::SET:
                $this->set($value);
                break;
            default:
                throw new InvalidArgumentException(sprintf(
                    'Invalid capture type provided; must be any of the capture '
                    . 'type constants, "%s" received.',
                    is_scalar($capture) ? $capture : gettype($capture)
                ));
        }

        return $this;
    }
1161250
public function push($fieldName, $value)
    {
        $oldValue = $this->get($fieldName);

        // check if old value is list or sub document
        // on sub document throw exception
        if (is_array($oldValue)) {
            $isSubDocument = (array_keys($oldValue) !== range(0, count($oldValue) - 1));
            if ($isSubDocument) {
                throw new InvalidOperationException(sprintf(
                    'The field "%s" must be an array but is of type Object',
                    $fieldName
                ));
            }
        }

        // prepare new value
        $value = Structure::prepareToStore($value);

        // field not exists
        if (!$oldValue) {
            if ($this->getId()) {
                $this->operator->push($fieldName, $value);
            }
            $value = array($value);
        } // field already exist and has single value
        elseif (!is_array($oldValue)) {
            $value = array_merge((array) $oldValue, array($value));
            if ($this->getId()) {
                $this->operator->set($fieldName, $value);
            }
        } // field exists and is array
        else {
            if ($this->getId()) {
                $setValue = $this->operator->get('$set', $fieldName);
                if ($setValue) {
                    $setValue[] = $value;
                    $this->operator->set($fieldName, $setValue);
                } else {
                    $this->operator->push($fieldName, $value);
                }
            }
            $value = array_merge($oldValue, array($value));
        }

        // update local data
        parent::set($fieldName, $value);

        return $this;
    }
620328
public function setValue($value)
    {
        if (!is_string($value) || (is_object($value) && !method_exists($value, "__toString"))) {
            throw new InvalidArgumentException(sprintf(
                "Invalid argument given to %s, expected a string, %s given",
                __METHOD__,
                is_object($value) ? get_class($value) : gettype($value)
            ));
        }

        $value = (string) $value;

        if (null !== $regex = $this->getValidationRegex()) {
            if (! preg_match($regex, $value)) {
                throw new InvalidArgumentException(sprintf(
                    "The given value '%s' doesn't match the validation regular expression: %s",
                    $value,
                    $regex
                ));
            }
        }

        $this->value = $value;

        return $this;
    }
985026
public function add($value)
    {
        if (!$value instanceof self) {
            $value = new self($value, $this->getScale(), false);
        }

        $newValue = bcadd($this->getValue(), $value->getValue(), $this->getScale());

        return $this->assignValue($newValue);
    }
135759
public function setValue($value)
    {
        if ((\is_bool($value))) {
            $this->value = (bool) $value;
        } elseif (\is_object($value) && $value instanceof self) {
            $this->value = $value->getValue();
        } else {
            throw new \InvalidArgumentException('Expected boolean');
        }
    }
295695
public function marshal($value)
    {
        if ($this->options()->allowed && !in_array($value, $this->options()->allowed)) {
            throw new \InvalidArgumentException(
                sprintf(
                    'Allowed values for this field are %s.',
                    implode(', ', $this->options()->allowed)
                )
            );
        }
        return new TypedValue((string) $value);
    }
1183006
protected function setValue($value)
    {
        if (!$this->validate($value)) {
            throw new \InvalidArgumentException(sprintf('%s is not a valid value', $value));
        }

        $this->value = $value;
    }
728378
public function push($option, $value)
	{
		if ( ! is_string($option))
		{
			throw new \InvalidArgumentException('The option value must be a string type.');
		}
		
		$this->heap[$option][] = $value;
	}
488794
public static function set($option, $value)
    {
        if (!array_key_exists($option, self::$conf))
        {
            throw new InvalidArgumentException(sprintf('Unknown option "%s"', $option));
        }

        $expected = gettype(self::$conf[$option]);
        $actual = gettype($value);
        if ($expected != $actual)
        {
            throw new InvalidArgumentException(
                sprintf('Option "%s" has type "%s", but "%s" given',
                    $option, $expected, $actual)
            );
        }

        self::$conf[$option] = $value;
    }
524538
public function boost($value)
    {
        if ($value < 0) {
            throw new InvalidArgumentException('Boost must not be negative.');
        }

        $this->boost = $this->processFloat($value);

        return $this;
    }
449176
protected function Add( $value )
	{
		switch ( $value->GetValueCode() )
		{
			case YearMonthDurationProxyFactory::Code:
				/**
				 * @var YearMonthDurationProxy $value
				 */
				// return new YearMonthDurationProxy( new YearMonthDurationValue( $this->_value->HighPartValue + (/* YearMonthDurationValue */ $value->getValue() )->HighPartValue));
				$clone = new YearMonthDurationValue( $this->_value->Value );
				$clone->Add( /* YearMonthDurationValue */ $value->getValue() );
				return new YearMonthDurationProxy( $clone );

			case DateTimeProxyFactory::Code:
				/**
				 * @var DateTimeProxy $value
				 */
				return new DateTimeProxy( DateTimeValue::AddYearMonthDuration( $value->getValue(), $this->_value ) );
				// return new DateTimeProxy( DateTimeValue::Add( /* DateTimeValue */ $value->getValue(), $this->_value ) );

			case DateProxyFactory::Code:
				/**
				 * @var DateProxy $value
				 */
				return new DateProxy( DateValue::AddYearMonthDuration( $value->getValue(), $this->_value ) );
				// return new DateProxy( DateValue::Add( /*DateValue */ $value->getValue(), $this->_value ) );

			default:
				throw XPath2Exception::withErrorCodeAndParams( "XPTY0004", Resources::BinaryOperatorNotDefined,
					array(
						"op:add",
						SequenceType::WithTypeCodeAndCardinality(SequenceType::GetXmlTypeCodeFromObject( $this->_value ), XmlTypeCardinality::One ),
						SequenceType::WithTypeCodeAndCardinality(SequenceType::GetXmlTypeCodeFromObject( $value->getValue() ), XmlTypeCardinality::One )
					)
				);
		}
	}
815073
public function set($value = null) 
    {
        if (is_null($value)) {
            $value = array();
        }
        
        if (!is_array($value)) {
            $value = func_get_args();
        }
        
        $this->__construct($value);
        
        return $this;
    }
247075
public function append($value)
  {
    $_internalVal = is_object($value) ? $value->__toString() : $value;
    array_push($this->_content, $_internalVal);
    return $this;
  }
18623
public function setValue($value)
    {
        if ($this->validation && !$this->validates($value)) {
            throw new Invalid($this->getValidationMessage($value));
        }

        if ($this->isMultiple()) {
            $this->value = $this->value === null ? [ $value ] : array_merge($this->value, [ $value ]);
        } else {
            $this->value = $value;
        }

        return $this;
    }
547322
public function setValue($value = null)
    {
        if ($value === null) {
            if (in_array($this->mode, [ GetOpt::REQUIRED_ARGUMENT, GetOpt::MULTIPLE_ARGUMENT ])) {
                throw new Missing(sprintf(
                    GetOpt::translate('option-argument-missing'),
                    $this->getName()
                ));
            }

            $value = $this->argument->getValue() +1;
        }

        $this->argument->setValue($value);

        return $this;
    }
447018
public function setValue($value = null)
    {
        if (is_callable($value)) {
            $value = call_user_func($value);
        }

        $value = $this->handleJsonType($value);

        $this->value = $value;

        return $this;
    }
670632
public function setAsFloat($value)
    {
        if (!(is_numeric($value) || $value instanceof NumericTypeInterface)) {
            throw new \InvalidArgumentException('value is not numeric');
        }
        $val = is_object($value) ? $value->asFloatType()->get() : floatval($value);
        $intVal = pow(10, $this->precision->get()) * $val;
        parent::set($intVal);

        return $this;
    }