Formulas/Resources/Formulas/Formula.php
private function getComponentAspectValue( $source, $aspect, $componentType, $evaluationResult, $log )
	{
		// Unlike other rules there is no one scenario rule. Instead is it made up of a collection of rules.
		// They must be processed in order to produce a final list of scenarios
		$rules = $componentType == 'segment' ? $this->segmentRule : $this->scenarioRule;

		if ( ! $rules )
		{
			$extra = in_array( $aspect, array( ASPECT_COMPLETE_SCENARIO, ASPECT_COMPLETE_SEGMENT ) ) ? '' : '';
			return $this->getComponentForPath( $source, ( $componentType == 'segment' ? $this->segmentsComponentPath : $this->scenariosComponentPath ), $extra, $evaluationResult, $aspect, $log, $contextRef );
		}

		$contextRef = null;
		$ruleContextRef = null;
		$context = array();

		foreach ( $rules as $rule )
		{
			// The context has to be rule source specific but cannot be replaced by the context for every rule
			$ruleContext = $this->getComponentForPath( $rule['source'], ( $componentType == 'segment' ? $this->segmentsComponentPath : $this->scenariosComponentPath ), 'member', $evaluationResult, $aspect, $log, $ruleContextRef );
			$context = is_null( $contextRef ) || $contextRef != $ruleContextRef
				? array_merge( $context, $ruleContext )
				: $context;

			if ( $contextRef != $ruleContextRef ) $contextRef = $ruleContextRef;

			if ( $rule['aspectType'] == 'occEmpty' ) // occEmtpy
			{
				$context = array();
			}
			else if ( $rule['aspectType'] == 'occFragments' ) // occFragments
			{
				/**
				 * @var OCCFragments $fragments
				 */
				$fragments = OCCFragments::fromArray( $rule );
				// This function will throw an exception if there is a problem so there is no return value to check
				$this->checkSAVConflicts( $fragments->source, $aspect, $evaluationResult, $log );
				$members = $fragments->getValue( $this, $evaluationResult, $log );
				$context = array_merge( $context, $members );
			}
			else if ( $rule['aspectType'] == 'occXpath' ) // occXpath
			{
				/**
				 * @var OCCXPath $xpath
				 */
				$xpath = OCCXPath::fromArray( $rule );
				// This function will throw an exception if there is a problem so there is no return value to check
				$this->checkSAVConflicts( $xpath->source, $aspect, $evaluationResult, $log );
				$members = $xpath->getValue( $this, $evaluationResult, $log );
				$context = array_merge( $context, $members );
			}

		}

		// BMS 2018-03-22 The call to getComponentForPath() above 'pops' the containing 'member'
		//				  element so if there are any elements in the context array wrap them
		//				  in a member element.
		if ( $context )
		{
			$context = array( 'member' => $context );
		}

		return $context;
	}
private function getComponentAspectValue( $source, $aspect, $componentType, $evaluationResult, $log )
	{
		// Unlike other rules there is no one scenario rule. Instead is it made up of a collection of rules.
		// They must be processed in order to produce a final list of scenarios
		$rules = $componentType == 'segment' ? $this->segmentRule : $this->scenarioRule;

		if ( ! $rules )
		{
			$extra = in_array( $aspect, array( ASPECT_COMPLETE_SCENARIO, ASPECT_COMPLETE_SEGMENT ) ) ? '' : '';
			return $this->getComponentForPath( $source, ( $componentType == 'segment' ? $this->segmentsComponentPath : $this->scenariosComponentPath ), $extra, $evaluationResult, $aspect, $log, $contextRef );
		}

		$contextRef = null;
		$ruleContextRef = null;
		$context = array();

		foreach ( $rules as $rule )
		{
			// The context has to be rule source specific but cannot be replaced by the context for every rule
			$ruleContext = $this->getComponentForPath( $rule['source'], ( $componentType == 'segment' ? $this->segmentsComponentPath : $this->scenariosComponentPath ), 'member', $evaluationResult, $aspect, $log, $ruleContextRef );
			$context = is_null( $contextRef ) || $contextRef != $ruleContextRef
				? array_merge( $context, $ruleContext )
				: $context;

			if ( $contextRef != $ruleContextRef ) $contextRef = $ruleContextRef;

			if ( $rule['aspectType'] == 'occEmpty' ) // occEmtpy
			{
				$context = array();
			}
			else if ( $rule['aspectType'] == 'occFragments' ) // occFragments
			{
				/**
				 * @var OCCFragments $fragments
				 */
				$fragments = OCCFragments::fromArray( $rule );
				// This function will throw an exception if there is a problem so there is no return value to check
				$this->checkSAVConflicts( $fragments->source, $aspect, $evaluationResult, $log );
				$members = $fragments->getValue( $this, $evaluationResult, $log );
				$context = array_merge( $context, $members );
			}
			else if ( $rule['aspectType'] == 'occXpath' ) // occXpath
			{
				/**
				 * @var OCCXPath $xpath
				 */
				$xpath = OCCXPath::fromArray( $rule );
				// This function will throw an exception if there is a problem so there is no return value to check
				$this->checkSAVConflicts( $xpath->source, $aspect, $evaluationResult, $log );
				$members = $xpath->getValue( $this, $evaluationResult, $log );
				$context = array_merge( $context, $members );
			}

		}

		// BMS 2018-03-22 The call to getComponentForPath() above 'pops' the containing 'member'
		//				  element so if there are any elements in the context array wrap them
		//				  in a member element.
		if ( $context )
		{
			$context = array( 'member' => $context );
		}

		return $context;
	}
private function getComponentAspectValue ( $ source , $ aspect , $ componentType , $ evaluationResult , $ log ) { // Unlike other rules there is no one scenario rule. Instead is it made up of a collection of rules.
 // They must be processed in order to produce a final list of scenarios
 $ rules = $ componentType == 'segment' ? $ this -> segmentRule : $ this -> scenarioRule ; if ( ! $ rules ) { $ extra = in_array ( $ aspect , array ( ASPECT_COMPLETE_SCENARIO , ASPECT_COMPLETE_SEGMENT ) ) ? '' : '' ; return $ this -> getComponentForPath ( $ source , ( $ componentType == 'segment' ? $ this -> segmentsComponentPath : $ this -> scenariosComponentPath ) , $ extra , $ evaluationResult , $ aspect , $ log , $ contextRef ) ; } $ contextRef = null ; $ ruleContextRef = null ; $ context = array ( ) ; foreach ( $ rules as $ rule ) { // The context has to be rule source specific but cannot be replaced by the context for every rule
 $ ruleContext = $ this -> getComponentForPath ( $ rule [ 'source' ] , ( $ componentType == 'segment' ? $ this -> segmentsComponentPath : $ this -> scenariosComponentPath ) , 'member' , $ evaluationResult , $ aspect , $ log , $ ruleContextRef ) ; $ context = is_null ( $ contextRef ) || $ contextRef != $ ruleContextRef ? array_merge ( $ context , $ ruleContext ) : $ context ; if ( $ contextRef != $ ruleContextRef ) $ contextRef = $ ruleContextRef ; if ( $ rule [ 'aspectType' ] == 'occEmpty' ) // occEmtpy
 { $ context = array ( ) ; } else if ( $ rule [ 'aspectType' ] == 'occFragments' ) // occFragments
 { /**
				 * @var OCCFragments $fragments
				 */ $ fragments = OCCFragments :: fromArray ( $ rule ) ; // This function will throw an exception if there is a problem so there is no return value to check
 $ this -> checkSAVConflicts ( $ fragments -> source , $ aspect , $ evaluationResult , $ log ) ; $ members = $ fragments -> getValue ( $ this , $ evaluationResult , $ log ) ; $ context = array_merge ( $ context , $ members ) ; } else if ( $ rule [ 'aspectType' ] == 'occXpath' ) // occXpath
 { /**
				 * @var OCCXPath $xpath
				 */ $ xpath = OCCXPath :: fromArray ( $ rule ) ; // This function will throw an exception if there is a problem so there is no return value to check
 $ this -> checkSAVConflicts ( $ xpath -> source , $ aspect , $ evaluationResult , $ log ) ; $ members = $ xpath -> getValue ( $ this , $ evaluationResult , $ log ) ; $ context = array_merge ( $ context , $ members ) ; } } // BMS 2018-03-22 The call to getComponentForPath() above 'pops' the containing 'member'
 //				  element so if there are any elements in the context array wrap them
 //				  in a member element.
 if ( $ context ) { $ context = array ( 'member' => $ context ) ; } return $ context ; }
Get the scenario to be used for this fact.  If a scenario rule does not exist, use the formula source value
@param array $source
@param string $aspect
@param string $componentType
@param array $evaluationResult
@param \XBRL_Log $log
@return array|NULL
Get the scenario to be used for this fact . If a scenario rule does not exist use the formula source value