Formulas/Resources/Formulas/GeneratedFacts.php
private function addComponent( $componentType, $component, &$document, $prefix, $xbrldiPrefix )
	{
		$entry[] = "<$componentType>";

		foreach ( $component as $memberType => $members )
		{
			switch ( $memberType )
			{
				case 'member':

					// $entry[] = "  <member>";

					foreach ( $members as $member )
					{
						$attributesList = array();
						$attributes = "";

						if ( isset( $member['attributes'] ) )
						{
							foreach ( $member['attributes'] as $name => $attribute )
							{
								$attributesList[] = "{$attribute['name']}=\"{$attribute['value']}\"";
							}

							$attributes = " " . implode( " ", $attributesList ) . " ";
						}

						if ( isset( $member['member'] ) )
						{
							if ( $member['member'] )
							{
								$entry[] = "  <{$member['name']}>{$member['member']}</{$member['name']}$attributes>";
							}
							else
							{
								$entry[] = "  <{$member['name']}$attributes/>";
							}
						}
						else if ( isset( $member['children'] ) )
						{
							$createXml = function( $member, $length, $attributes = null ) use( &$createXml, &$entry )
							{
								$padding = str_pad( "", $length, " ");

								if ( isset( $member['children'] ) )
								{
									$entry[] = $padding . "<{$member['prefix']}:{$member['name']}$attributes>";
									foreach ( $member['children'] as $child )
									{
										$createXml( $child, $length + 2 );
									}
									$entry[] = $padding . "</{$member['prefix']}:{$member['name']}>";
								}
								else
								{
									$entry[] = $padding. "<{$member['prefix']}:{$member['name']}$attributes/>";
								}
							};

							$createXml( $member, 2, $attributes);
						}
					}

					// $entry[] = "  </member>";

					break;

				case 'explicitMember':

					foreach ( $members as $member )
					{
						$entry[] = "  <$xbrldiPrefix:explicitMember dimension=\"{$member['dimension']}\">{$member['member']}</$xbrldiPrefix:explicitMember>";
					}

					break;

				case 'typedMember':

					foreach ( $members as $member )
					{
						$entry[] = "  <$xbrldiPrefix:typedMember dimension=\"{$member['dimension']}\">";
						foreach ( $member['member'] as $valueName => $names )
						{
							if ( is_array( $names ) )
							{
								foreach ( $names as $name )
								{
									// $entry[] = "    <$valueName>$name</$valueName>";
									$entry[] = "    $name";
								}
							}
							else
							{
								$entry[] = "    <$valueName>$names</$valueName>";
							}
						}
						$entry[] = "  </$xbrldiPrefix:typedMember>";
					}

					break;
			}
		}

		$entry[] = "</$componentType>";

		$document[] = $prefix . implode( "\n$prefix", $entry );
	}
private function addComponent( $componentType, $component, &$document, $prefix, $xbrldiPrefix )
	{
		$entry[] = "<$componentType>";

		foreach ( $component as $memberType => $members )
		{
			switch ( $memberType )
			{
				case 'member':

					// $entry[] = "  <member>";

					foreach ( $members as $member )
					{
						$attributesList = array();
						$attributes = "";

						if ( isset( $member['attributes'] ) )
						{
							foreach ( $member['attributes'] as $name => $attribute )
							{
								$attributesList[] = "{$attribute['name']}=\"{$attribute['value']}\"";
							}

							$attributes = " " . implode( " ", $attributesList ) . " ";
						}

						if ( isset( $member['member'] ) )
						{
							if ( $member['member'] )
							{
								$entry[] = "  <{$member['name']}>{$member['member']}</{$member['name']}$attributes>";
							}
							else
							{
								$entry[] = "  <{$member['name']}$attributes/>";
							}
						}
						else if ( isset( $member['children'] ) )
						{
							$createXml = function( $member, $length, $attributes = null ) use( &$createXml, &$entry )
							{
								$padding = str_pad( "", $length, " ");

								if ( isset( $member['children'] ) )
								{
									$entry[] = $padding . "<{$member['prefix']}:{$member['name']}$attributes>";
									foreach ( $member['children'] as $child )
									{
										$createXml( $child, $length + 2 );
									}
									$entry[] = $padding . "</{$member['prefix']}:{$member['name']}>";
								}
								else
								{
									$entry[] = $padding. "<{$member['prefix']}:{$member['name']}$attributes/>";
								}
							};

							$createXml( $member, 2, $attributes);
						}
					}

					// $entry[] = "  </member>";

					break;

				case 'explicitMember':

					foreach ( $members as $member )
					{
						$entry[] = "  <$xbrldiPrefix:explicitMember dimension=\"{$member['dimension']}\">{$member['member']}</$xbrldiPrefix:explicitMember>";
					}

					break;

				case 'typedMember':

					foreach ( $members as $member )
					{
						$entry[] = "  <$xbrldiPrefix:typedMember dimension=\"{$member['dimension']}\">";
						foreach ( $member['member'] as $valueName => $names )
						{
							if ( is_array( $names ) )
							{
								foreach ( $names as $name )
								{
									// $entry[] = "    <$valueName>$name</$valueName>";
									$entry[] = "    $name";
								}
							}
							else
							{
								$entry[] = "    <$valueName>$names</$valueName>";
							}
						}
						$entry[] = "  </$xbrldiPrefix:typedMember>";
					}

					break;
			}
		}

		$entry[] = "</$componentType>";

		$document[] = $prefix . implode( "\n$prefix", $entry );
	}
private function addComponent ( $ componentType , $ component , & $ document , $ prefix , $ xbrldiPrefix ) { $ entry [ ] = "<$componentType>" ; foreach ( $ component as $ memberType => $ members ) { switch ( $ memberType ) { case 'member' : // $entry[] = "  <member>";
 foreach ( $ members as $ member ) { $ attributesList = array ( ) ; $ attributes = "" ; if ( isset ( $ member [ 'attributes' ] ) ) { foreach ( $ member [ 'attributes' ] as $ name => $ attribute ) { $ attributesList [ ] = "{$attribute['name']}=\"{$attribute['value']}\"" ; } $ attributes = " " . implode ( " " , $ attributesList ) . " " ; } if ( isset ( $ member [ 'member' ] ) ) { if ( $ member [ 'member' ] ) { $ entry [ ] = "  <{$member['name']}>{$member['member']}</{$member['name']}$attributes>" ; } else { $ entry [ ] = "  <{$member['name']}$attributes/>" ; } } else if ( isset ( $ member [ 'children' ] ) ) { $ createXml = function ( $ member , $ length , $ attributes = null ) use ( & $ createXml , & $ entry ) { $ padding = str_pad ( "" , $ length , " " ) ; if ( isset ( $ member [ 'children' ] ) ) { $ entry [ ] = $ padding . "<{$member['prefix']}:{$member['name']}$attributes>" ; foreach ( $ member [ 'children' ] as $ child ) { $ createXml ( $ child , $ length + 2 ) ; } $ entry [ ] = $ padding . "</{$member['prefix']}:{$member['name']}>" ; } else { $ entry [ ] = $ padding . "<{$member['prefix']}:{$member['name']}$attributes/>" ; } } ; $ createXml ( $ member , 2 , $ attributes ) ; } } // $entry[] = "  </member>";
 break ; case 'explicitMember' : foreach ( $ members as $ member ) { $ entry [ ] = "  <$xbrldiPrefix:explicitMember dimension=\"{$member['dimension']}\">{$member['member']}</$xbrldiPrefix:explicitMember>" ; } break ; case 'typedMember' : foreach ( $ members as $ member ) { $ entry [ ] = "  <$xbrldiPrefix:typedMember dimension=\"{$member['dimension']}\">" ; foreach ( $ member [ 'member' ] as $ valueName => $ names ) { if ( is_array ( $ names ) ) { foreach ( $ names as $ name ) { // $entry[] = "    <$valueName>$name</$valueName>";
 $ entry [ ] = "    $name" ; } } else { $ entry [ ] = "    <$valueName>$names</$valueName>" ; } } $ entry [ ] = "  </$xbrldiPrefix:typedMember>" ; } break ; } } $ entry [ ] = "</$componentType>" ; $ document [ ] = $ prefix . implode ( "\n$prefix" , $ entry ) ; }
Add the details for an OCC
@param string $componentType Scenario or segment
@param array $component A list of componets for the component type
@param array $document An array of lines
@param string $prefix The text (spaces) to add as a prefix to the line
@param string $xbrldiPrefix The xbrldi prefix to use in this generated document
Add the details for an OCC