Formulas/Resources/Assertions/ConsistencyAssertion.php
private function evaluateAcceptanceRadius( $variableSet, $derivedValue, $fact, $factVars = array() )
	{
		if ( is_null( $this->radiusValue ) )
		{
			if ( ! is_null( $this->absoluteAcceptanceRadius ) || ! is_null( $this->proportionalAcceptanceRadius ) )
			{
				$expression = ! is_null( $this->absoluteAcceptanceRadius )
					? $this->absoluteAcceptanceRadius
					: $this->proportionalAcceptanceRadius;

				$expression = "$expression cast as xs:float";

				$vars = array_map( function( $param ) { return $param->result; }, $this->parameters );
				$vars = array_merge( $factVars, $vars );
				// $result = $this->evaluateXPath( $variableSet, $expression, $vars );
				$provider = new NodeProvider( $fact );

				$xpathExpression = XPath2Expression::Compile( $expression, $variableSet->nsMgr );

				$xpathExpression->AddToContext( "xbrlInstance", $variableSet->xbrlInstance );
				$xpathExpression->AddToContext( "xbrlTaxonomy", $variableSet->xbrlTaxonomy );
				$xpathExpression->AddToContext( "base", $variableSet->base );
				$result = $xpathExpression->EvaluateWithVars( $provider, $vars );

				$this->radiusValue = $result instanceof XPath2Item ? $result->getTypedValue() : $result;
			}
			else
			{
				$this->radiusValue = false;
			}
		}

		if ( ! is_null( $this->absoluteAcceptanceRadius ) )
		{
			return $this->radiusValue;
		}

		if ( ! is_null( $this->proportionalAcceptanceRadius ) )
		{
			return $this->radiusValue * $derivedValue;
		}

		return null;
	}
private function evaluateAcceptanceRadius( $variableSet, $derivedValue, $fact, $factVars = array() )
	{
		if ( is_null( $this->radiusValue ) )
		{
			if ( ! is_null( $this->absoluteAcceptanceRadius ) || ! is_null( $this->proportionalAcceptanceRadius ) )
			{
				$expression = ! is_null( $this->absoluteAcceptanceRadius )
					? $this->absoluteAcceptanceRadius
					: $this->proportionalAcceptanceRadius;

				$expression = "$expression cast as xs:float";

				$vars = array_map( function( $param ) { return $param->result; }, $this->parameters );
				$vars = array_merge( $factVars, $vars );
				// $result = $this->evaluateXPath( $variableSet, $expression, $vars );
				$provider = new NodeProvider( $fact );

				$xpathExpression = XPath2Expression::Compile( $expression, $variableSet->nsMgr );

				$xpathExpression->AddToContext( "xbrlInstance", $variableSet->xbrlInstance );
				$xpathExpression->AddToContext( "xbrlTaxonomy", $variableSet->xbrlTaxonomy );
				$xpathExpression->AddToContext( "base", $variableSet->base );
				$result = $xpathExpression->EvaluateWithVars( $provider, $vars );

				$this->radiusValue = $result instanceof XPath2Item ? $result->getTypedValue() : $result;
			}
			else
			{
				$this->radiusValue = false;
			}
		}

		if ( ! is_null( $this->absoluteAcceptanceRadius ) )
		{
			return $this->radiusValue;
		}

		if ( ! is_null( $this->proportionalAcceptanceRadius ) )
		{
			return $this->radiusValue * $derivedValue;
		}

		return null;
	}
private function evaluateAcceptanceRadius ( $ variableSet , $ derivedValue , $ fact , $ factVars = array ( ) ) { if ( is_null ( $ this -> radiusValue ) ) { if ( ! is_null ( $ this -> absoluteAcceptanceRadius ) || ! is_null ( $ this -> proportionalAcceptanceRadius ) ) { $ expression = ! is_null ( $ this -> absoluteAcceptanceRadius ) ? $ this -> absoluteAcceptanceRadius : $ this -> proportionalAcceptanceRadius ; $ expression = "$expression cast as xs:float" ; $ vars = array_map ( function ( $ param ) { return $ param -> result ; } , $ this -> parameters ) ; $ vars = array_merge ( $ factVars , $ vars ) ; // $result = $this->evaluateXPath( $variableSet, $expression, $vars );
 $ provider = new NodeProvider ( $ fact ) ; $ xpathExpression = XPath2Expression :: Compile ( $ expression , $ variableSet -> nsMgr ) ; $ xpathExpression -> AddToContext ( "xbrlInstance" , $ variableSet -> xbrlInstance ) ; $ xpathExpression -> AddToContext ( "xbrlTaxonomy" , $ variableSet -> xbrlTaxonomy ) ; $ xpathExpression -> AddToContext ( "base" , $ variableSet -> base ) ; $ result = $ xpathExpression -> EvaluateWithVars ( $ provider , $ vars ) ; $ this -> radiusValue = $ result instanceof XPath2Item ? $ result -> getTypedValue ( ) : $ result ; } else { $ this -> radiusValue = false ; } } if ( ! is_null ( $ this -> absoluteAcceptanceRadius ) ) { return $ this -> radiusValue ; } if ( ! is_null ( $ this -> proportionalAcceptanceRadius ) ) { return $ this -> radiusValue * $ derivedValue ; } return null ; }
Check the value is wthin the acceptance radius
@param Formula $variableSet
@param mixed $derivedValue
@param XPathNavigator $fact
@param array $factVars
@return number|NULL
Check the value is wthin the acceptance radius