Create
@param object $value
@return ValueProxy
197635
public static function Create( $value )
	{
		if ( $value instanceof ValueProxy )
			return $value;
		try
		{
			if ( $value instanceof XPath2Item )
			{
				$valueType = $value->getValueType();
				$typeName = $valueType->getTypeName();
				$value = $value->getTypedValue();
			}
			else if ( $value instanceof IXmlSchemaType )
			{
				$typeName = $value::$CLASSNAME;
			}
			else
			{
				$typeName = Type::FromValue( $value )->getTypeName();
			}

			if ( ! isset( ValueProxy::$valueFactory[ $typeName ] ) )
			{
				throw new KeyNotFoundException();
			}

			return ValueProxy::$valueFactory[ $typeName ]->Create( $value );
		}
		catch ( KeyNotFoundException $ex )
		{
			$className = get_class( $value );
			if ( is_null( $value ) )
				throw XPath2Exception::withErrorCodeAndParam( "XPTY0004", "The type {0} is not registred in ValueProxy", $className);
			else
				throw new InvalidCastException( "The type {$className} is not registred in ValueProxy" );
		}
	}
77707
public static function proxyPort($value = null)
    {
        if (empty($value)) {
            return self::$global->getProxyPort();
        }
        self::$global->setProxyPort($value);
    }
1143812
protected function Sub($value)
	{
		switch ( $value->GetValueCode() )
		{
			case DateTimeProxyFactory::Code:
				return new DayTimeDurationProxy( DateTimeValue::Sub( $this->_value, /* DateTimeValue */ $value->getValue() ) );

			case YearMonthDurationProxyFactory::Code:
				/**
				 * @var DayTimeDurationProxy $value
				 */
				// Clone the DateValue contained in the proxy or the original is changed
				$clone = DateTimeValue::fromDate( $this->_value->S, clone $this->_value->Value, ! $this->_value->IsLocal );
				$value->getValue()->Value->invert = ! $value->getValue()->Value->invert;
				return new DateTimeProxy( DateTimeValue::AddYearMonthDuration( $clone, $value->getValue() ) );
				// return new DateTimeProxy( DateTimeValue::Add( $this->_value, - /* YearMonthDurationValue */ $value->getValue() ) );

			case DayTimeDurationProxyFactory::Code:
				/**
				 * @var DayTimeDurationProxy $value
				 */
				// Clone the DateValue contained in the proxy or the original is changed
				$clone = DateTimeValue::fromDate( $this->_value->S, clone $this->_value->Value, ! $this->_value->IsLocal );
				$value->getValue()->Value->invert = ! $value->getValue()->Value->invert;
				return new DateTimeProxy( DateTimeValue::AddDayTimeDuration( $clone, $value->getValue() ) );
				// return new DateTimeProxy( DateTimeValue::Add( $this->_value, - /* DayTimeDurationValue */ $value->getValue() ) );

			default:
				throw XPath2Exception::withErrorCodeAndParams("XPTY0004", Resources::BinaryOperatorNotDefined,
					array(
						"op:sub",
						SequenceType::WithTypeCodeAndCardinality( SequenceType::GetXmlTypeCodeFromObject( $this->_value), XmlTypeCardinality::One ),
						SequenceType::WithTypeCodeAndCardinality( SequenceType::GetXmlTypeCodeFromObject( $value->getValue() ), XmlTypeCardinality::One )
					)
				);
		}
	}
451018
public function setCoreProxyAuthType($value)
    {
        $this->setFieldName('proxy_auth_type');
        $this->loadObject(true);
        $this->setFieldValue($value);

        return $this;
    }
1353347
protected function createObjectFromArray(array &$value)
    {
        if (array_key_exists('$ref', $value) && is_string($value['$ref'])) {
            return $this->createReferenceFromArray($value);
        }

        $instance = new Value\ObjectValue;
        $this->register($value, $instance);

        foreach ($value as $key => &$subValue) {
            $instance->set($key, $this->createValue($subValue));
        }

        return $instance;
    }
480177
protected function castToObject($value)
    {
        if (is_scalar($value) || is_resource($value)) {
            $value = $this->dontCast($value);
        }

        return (object)$value;
    }
1338895
public function setValue($object, $value = null)
    {
        if (! ($object instanceof Proxy && ! $object->__isInitialized())) {
            parent::setValue($object, $value);

            return;
        }

        $originalInitializer = $object->__getInitializer();
        $object->__setInitializer(null);
        parent::setValue($object, $value);
        $object->__setInitializer($originalInitializer);
    }
137993
protected function Div( $value )
	{
	    if ( $value->getIsNumeric() )
	        return new DayTimeDurationProxy( DayTimeDurationValue::Divide(  $this->_value, Convert::ToDouble( $value->getValue() ) ) );

	    else if ( $value->GetValueCode() == DayTimeDurationProxyFactory::Code )
	        return new DecimalProxy( DayTimeDurationValue::DivideDurations( $this->_value, /* DayTimeDurationValue */ $value->getValue() ) );

	    else
	        throw XPath2Exception::withErrorCodeAndParams( "XPTY0004", Resources::BinaryOperatorNotDefined,
				array(
					"op:div",
					SequenceType::WithTypeCodeAndCardinality( SequenceType::GetXmlTypeCodeFromObject(  $this->_value), XmlTypeCardinality::One ),
					SequenceType::WithTypeCodeAndCardinality( SequenceType::GetXmlTypeCodeFromObject( $value->getValue() ), XmlTypeCardinality::One )
				)
			);
	}
705006
protected function createReferenceFromObject(stdClass &$value)
    {
        $uri = new Uri($value->{'$ref'});
        $mimeType = null;
        if (property_exists($value, '$type') && is_string($value->{'$type'})) {
            $mimeType = $value->{'$type'};
        }

        return $this->register(
            $value,
            new Value\ReferenceValue($uri, $mimeType)
        );
    }
377206
public static function createFromJsonObject(string $value)
    {
        $json = \json_decode($value, true);
        if (!\is_array($json)) {
            throw new \InvalidArgumentException('Invalid key or key set.');
        }

        return self::createFromValues($json);
    }
1095287
private function makeSerializable($value)
    {
        if (null === $value) {
            return $value;
        }

        if ($value instanceof Traversable || is_array($value)) {
            $value = ArrayUtils::iteratorToArray($value);

            foreach ($value as $key => $val) {
                $value[$key] = $this->makeSerializable($val);
            }

            return $value;
        }

        if (is_scalar($value)) {
            return $value;
        }

        if (is_resource($value)) {
            return 'resource';
        }

        return new ObjectStub($value);
    }
685012
protected function Sub( $value )
	{
	    switch ( $value->GetValueCode() )
	    {
	        case DayTimeDurationProxyFactory::Code:
	        	/**
	        	 * @var DayTimeDurationProxy $value
	        	 */
	            // return new DayTimeDurationProxy( new DayTimeDurationValue(  $this->_value->Value - /* DayTimeDurationValue */ $value->getValue()->Value ) );
	            $clone = new DayTimeDurationValue( $this->_value->Value );
	            $clone->Sub( /* DayTimeDurationValue */ $value->getValue() );
	            return new DayTimeDurationProxy( $clone );

	        default:
	            throw XPath2Exception::withErrorCodeAndParams( "XPTY0004", Resources::BinaryOperatorNotDefined,
					array(
						"op:sub",
						SequenceType::WithTypeCodeAndCardinality( SequenceType::GetXmlTypeCodeFromObject(  $this->_value), XmlTypeCardinality::One ),
						SequenceType::WithTypeCodeAndCardinality( SequenceType::GetXmlTypeCodeFromObject( $value->getValue() ), XmlTypeCardinality::One )
					)
				);
	    }
	}
918161
public function extend($name, $value)
    {
        if (is_callable($value)) {
            $this->extensions[$name] = $value;
        } else {
            $this->extensions[$name] = function ($ontraport) use ($value) {
                return new $value($ontraport);
            };
        }

        return $this;
    }
899333
public static function create($value)
    {
        if ($value instanceof \Exception) {
            return new Failure($value);
        }
        try {
            if ($value instanceof \Closure) {
                //test to ensure function doesn't throw exception or is an Exception
                $potentialException = $value();
                if ($potentialException instanceof \Exception) {
                    return new Failure($potentialException);
                }
            } elseif ($value instanceof Monadic) {
                return static::create($value->flatten());
            }

            return new Success($value);

        } catch (\Exception $e) {
            return new Failure($e);
        }
    }
971355
public function setRootCreated( $value )
    {
        $content = $this->getDependentContent();

        if ( $content )
        {
            $content->created = $value;
        }

        return $this;
    }
518758
public static function factory($value)
    {
        
        if ($value instanceof self) {
            $value = $value->getValue();
        }
        
        $value = static::filter($value);
        
        if (!is_scalar($value)) {
            throw new ErrorException("A value object must be created from a scalar value!");
        }
        
        $classname = get_called_class();
        
        if (!isset(self::$instances[$classname])) {
            self::$instances[$classname] = array();
        }
    
        // lazy load the value-object
        if (!isset(self::$instances[$classname][$value])) {
            if (func_num_args()>1) {
                // construct value-object with more then the pure scalar value
                // (not really correct in terms of value-objects, but sometimes needed)
                $arguments = func_get_args();
                $reflection = new \ReflectionClass($classname);
                self::$instances[$classname][$value] = $reflection->newInstanceArgs($arguments);
                
            } else {
                self::$instances[$classname][$value] = new static($value);
            }
        }
    
        return self::$instances[$classname][$value];
    }
1267385
public function newInstance($value = null)
    {
        $class = $this->getClassName();
        $o = new $class($value, $this->encoding);
        return $o;
    }