XBRL-Instance.php
public function ElementsByContexts( $contexts )
	{
		if ( is_string( $contexts ) )
			$contexts = array_map( 'trim', explode( ",", $contexts ) );

		if ( is_a( $contexts, 'ContextsFilter' ) )
			$contexts = $contexts->Keys();

		if ( ! is_array( $contexts ) )
			throw new Exception( 'InstanceElementsFilter::ElementsByName $contexts must be a string or array' );

		$contexts = array_flip( array_map( 'strtolower', $contexts ) );

		// In PHP 7.0 $this is passed to closure functions automatically but not in earlier versions
		$elements = &$this->elements;

		$filtered = array_reduce( array_keys( $this->elements ), function( $carry, $elementName ) use( $contexts, &$elements ) {

			$contextElements = array_filter( $elements[ $elementName ], function( $element ) use( &$contexts, &$elements ) {

				if ( isset( $element['contextRef'] ) )
				{
					return isset( $contexts[ strtolower( $element['contextRef'] ) ] );
				}

				// Could be a tuple in which case the tuple members should be checked
				return array_reduce( $element['tuple_elements'], function( $carry, $tuple_element ) use( $contexts ) {

					if ( $carry ) return true; // Once one valid member is found there's no need to look for any others
					return array_reduce( $tuple_element, function( $carry, $entry ) use( $contexts ) {

						if ( $carry ) return true; // Once one valid member is found there's no need to look for any others
						return isset( $contexts[ strtolower( $entry['contextRef'] ) ] );

					} );

				}, false );

			} );

			if ( ! $contextElements ) return $carry;

			$carry[ $elementName ] = $contextElements;

			return $carry;

		}, array() );

		return new InstanceElementsFilter( $this->instance, $filtered );
	}
public function ElementsByContexts( $contexts )
	{
		if ( is_string( $contexts ) )
			$contexts = array_map( 'trim', explode( ",", $contexts ) );

		if ( is_a( $contexts, 'ContextsFilter' ) )
			$contexts = $contexts->Keys();

		if ( ! is_array( $contexts ) )
			throw new Exception( 'InstanceElementsFilter::ElementsByName $contexts must be a string or array' );

		$contexts = array_flip( array_map( 'strtolower', $contexts ) );

		// In PHP 7.0 $this is passed to closure functions automatically but not in earlier versions
		$elements = &$this->elements;

		$filtered = array_reduce( array_keys( $this->elements ), function( $carry, $elementName ) use( $contexts, &$elements ) {

			$contextElements = array_filter( $elements[ $elementName ], function( $element ) use( &$contexts, &$elements ) {

				if ( isset( $element['contextRef'] ) )
				{
					return isset( $contexts[ strtolower( $element['contextRef'] ) ] );
				}

				// Could be a tuple in which case the tuple members should be checked
				return array_reduce( $element['tuple_elements'], function( $carry, $tuple_element ) use( $contexts ) {

					if ( $carry ) return true; // Once one valid member is found there's no need to look for any others
					return array_reduce( $tuple_element, function( $carry, $entry ) use( $contexts ) {

						if ( $carry ) return true; // Once one valid member is found there's no need to look for any others
						return isset( $contexts[ strtolower( $entry['contextRef'] ) ] );

					} );

				}, false );

			} );

			if ( ! $contextElements ) return $carry;

			$carry[ $elementName ] = $contextElements;

			return $carry;

		}, array() );

		return new InstanceElementsFilter( $this->instance, $filtered );
	}
public function ElementsByContexts ( $ contexts ) { if ( is_string ( $ contexts ) ) $ contexts = array_map ( 'trim' , explode ( "," , $ contexts ) ) ; if ( is_a ( $ contexts , 'ContextsFilter' ) ) $ contexts = $ contexts -> Keys ( ) ; if ( ! is_array ( $ contexts ) ) throw new Exception ( 'InstanceElementsFilter::ElementsByName $contexts must be a string or array' ) ; $ contexts = array_flip ( array_map ( 'strtolower' , $ contexts ) ) ; // In PHP 7.0 $this is passed to closure functions automatically but not in earlier versions
 $ elements = & $ this -> elements ; $ filtered = array_reduce ( array_keys ( $ this -> elements ) , function ( $ carry , $ elementName ) use ( $ contexts , & $ elements ) { $ contextElements = array_filter ( $ elements [ $ elementName ] , function ( $ element ) use ( & $ contexts , & $ elements ) { if ( isset ( $ element [ 'contextRef' ] ) ) { return isset ( $ contexts [ strtolower ( $ element [ 'contextRef' ] ) ] ) ; } // Could be a tuple in which case the tuple members should be checked
 return array_reduce ( $ element [ 'tuple_elements' ] , function ( $ carry , $ tuple_element ) use ( $ contexts ) { if ( $ carry ) return true ; // Once one valid member is found there's no need to look for any others
 return array_reduce ( $ tuple_element , function ( $ carry , $ entry ) use ( $ contexts ) { if ( $ carry ) return true ; // Once one valid member is found there's no need to look for any others
 return isset ( $ contexts [ strtolower ( $ entry [ 'contextRef' ] ) ] ) ; } ) ; } , false ) ; } ) ; if ( ! $ contextElements ) return $ carry ; $ carry [ $ elementName ] = $ contextElements ; return $ carry ; } , array ( ) ) ; return new InstanceElementsFilter ( $ this -> instance , $ filtered ) ; }
Return a list of elements based on a set of contexts
@param array|string $contexts The parameter can be the name of an context, a comma delimited list of contexts or an array of contexts
@throws Exception
@return InstanceElementsFilter
Return a list of elements based on a set of contexts