repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1
value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
bseddon/XBRL | XBRL-Log.php | XBRL_Log.business_rules_validation | public function business_rules_validation( $section, $message, $source )
{
if ( ! $this->log ) return;
$this->businessRulesViolationeWarning = true;
$msg = sprintf( "[business rules] $message (Section %s - %s)", $section, $this->arrayToDescription( $source ) );
$this->log->_announce( array( 'section' => $section, 'priority' => PEAR_LOG_WARNING, 'message' => $message, 'source' => $source ) );
return $this->log->warning( $msg );
} | php | public function business_rules_validation( $section, $message, $source )
{
if ( ! $this->log ) return;
$this->businessRulesViolationeWarning = true;
$msg = sprintf( "[business rules] $message (Section %s - %s)", $section, $this->arrayToDescription( $source ) );
$this->log->_announce( array( 'section' => $section, 'priority' => PEAR_LOG_WARNING, 'message' => $message, 'source' => $source ) );
return $this->log->warning( $msg );
} | [
"public",
"function",
"business_rules_validation",
"(",
"$",
"section",
",",
"$",
"message",
",",
"$",
"source",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"log",
")",
"return",
";",
"$",
"this",
"->",
"businessRulesViolationeWarning",
"=",
"true",
";",
... | A convenience function for logging a event about an XBRL business rules violation issue.
It will log a message at the PEAR_LOG_WARNING log level.
PEAR_LOG_WARNING
@param string $section The rules topic reference
@param string $message String or object containing the message to log.
@param array $source An array containing details about the source such as the element id, link base, etc.
@return boolean True if the message was successfully logged. | [
"A",
"convenience",
"function",
"for",
"logging",
"a",
"event",
"about",
"an",
"XBRL",
"business",
"rules",
"violation",
"issue",
".",
"It",
"will",
"log",
"a",
"message",
"at",
"the",
"PEAR_LOG_WARNING",
"log",
"level",
"."
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Log.php#L338-L345 | train |
bseddon/XBRL | XBRL-Log.php | XBRL_Log.formula_validation | public function formula_validation( $section, $message, $source )
{
if ( ! $this->log ) return;
$this->conformanceIssueWarning = true;
$errorMessage = sprintf( "[formula] $message (Section %s - %s)", $section, $this->arrayToDescription( $source ) );
$this->log->_announce( array( 'section' => $section, 'priority' => PEAR_LOG_WARNING, 'message' => $message, 'source' => $source ) );
$this->log->warning( $errorMessage );
if ( isset( $source['error'] ) )
{
throw FormulasException::withType( $source['error'], "formula", $errorMessage );
}
return $errorMessage;
} | php | public function formula_validation( $section, $message, $source )
{
if ( ! $this->log ) return;
$this->conformanceIssueWarning = true;
$errorMessage = sprintf( "[formula] $message (Section %s - %s)", $section, $this->arrayToDescription( $source ) );
$this->log->_announce( array( 'section' => $section, 'priority' => PEAR_LOG_WARNING, 'message' => $message, 'source' => $source ) );
$this->log->warning( $errorMessage );
if ( isset( $source['error'] ) )
{
throw FormulasException::withType( $source['error'], "formula", $errorMessage );
}
return $errorMessage;
} | [
"public",
"function",
"formula_validation",
"(",
"$",
"section",
",",
"$",
"message",
",",
"$",
"source",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"log",
")",
"return",
";",
"$",
"this",
"->",
"conformanceIssueWarning",
"=",
"true",
";",
"$",
"erro... | A convenience function for logging a event about an XBRL formula specification conformance issue.
It will log a message at the PEAR_LOG_DEBUG log level.
PEAR_LOG_WARNING
@param string $section The specification section reference
@param string $message String or object containing the message to log.
@param array $source An array containing details about the source such as the element id, link base, etc.
@return boolean True if the message was successfully logged. | [
"A",
"convenience",
"function",
"for",
"logging",
"a",
"event",
"about",
"an",
"XBRL",
"formula",
"specification",
"conformance",
"issue",
".",
"It",
"will",
"log",
"a",
"message",
"at",
"the",
"PEAR_LOG_DEBUG",
"log",
"level",
"."
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Log.php#L358-L370 | train |
bseddon/XBRL | XBRL-Log.php | XBRL_Log.formula_evaluation | public function formula_evaluation( $section, $message, $source )
{
if ( ! $this->log ) return;
$message = "$section $message";
$this->log->_announce( array( 'section' => $section, 'priority' => PEAR_LOG_INFO, 'message' => $message, 'source' => $source ) );
$this->log->info( $message );
return $message;
} | php | public function formula_evaluation( $section, $message, $source )
{
if ( ! $this->log ) return;
$message = "$section $message";
$this->log->_announce( array( 'section' => $section, 'priority' => PEAR_LOG_INFO, 'message' => $message, 'source' => $source ) );
$this->log->info( $message );
return $message;
} | [
"public",
"function",
"formula_evaluation",
"(",
"$",
"section",
",",
"$",
"message",
",",
"$",
"source",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"log",
")",
"return",
";",
"$",
"message",
"=",
"\"$section $message\"",
";",
"$",
"this",
"->",
"log... | A convenience function for logging a formula evaluation result event.
It will log a message at the PEAR_LOG_INFO log level.
PEAR_LOG_INFO
@param string $section The specification section reference
@param string $message String or object containing the message to log.
@param array $source An array containing details about the source such as the element id, link base, etc.
@return boolean True if the message was successfully logged. | [
"A",
"convenience",
"function",
"for",
"logging",
"a",
"formula",
"evaluation",
"result",
"event",
".",
"It",
"will",
"log",
"a",
"message",
"at",
"the",
"PEAR_LOG_INFO",
"log",
"level",
"."
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Log.php#L456-L463 | train |
bseddon/XBRL | XBRL-Log.php | XBRL_Log.instance_validation | public function instance_validation( $section, $message, $source )
{
if ( ! $this->log ) return;
$this->instanceValidationWarning = true;
// Concatenate the key and the value
$msg = sprintf( "[instance] $message (Section %s - %s)", $section, $this->arrayToDescription( $source ) );
$this->log->_announce( array( 'section' => $section, 'priority' => PEAR_LOG_WARNING, 'message' => $message, 'source' => $source ) );
return $this->log->warning( $msg );
} | php | public function instance_validation( $section, $message, $source )
{
if ( ! $this->log ) return;
$this->instanceValidationWarning = true;
// Concatenate the key and the value
$msg = sprintf( "[instance] $message (Section %s - %s)", $section, $this->arrayToDescription( $source ) );
$this->log->_announce( array( 'section' => $section, 'priority' => PEAR_LOG_WARNING, 'message' => $message, 'source' => $source ) );
return $this->log->warning( $msg );
} | [
"public",
"function",
"instance_validation",
"(",
"$",
"section",
",",
"$",
"message",
",",
"$",
"source",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"log",
")",
"return",
";",
"$",
"this",
"->",
"instanceValidationWarning",
"=",
"true",
";",
"// Conca... | A convenience function for logging an event about an XBRL instance specification conformance issue.
It will log a message at the PEAR_LOG_DEBUG log level.
PEAR_LOG_WARNING
@param string $section The specification section reference
@param string $message String or object containing the message to log.
@param array $source An array containing details about the source such as the element id, segment, period, etc.
@return boolean True if the message was successfully logged. | [
"A",
"convenience",
"function",
"for",
"logging",
"an",
"event",
"about",
"an",
"XBRL",
"instance",
"specification",
"conformance",
"issue",
".",
"It",
"will",
"log",
"a",
"message",
"at",
"the",
"PEAR_LOG_DEBUG",
"log",
"level",
"."
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Log.php#L476-L484 | train |
bseddon/XBRL | XBRL-Log.php | XBRL_Log.conformance_issue | public function conformance_issue( $testid, $message, $source )
{
if ( ! $this->log ) return;
$this->conformanceIssueWarning = true;
// Concatenate the key and the value
return $this->log->warning( sprintf( "[instance] $message (Section %s - %s)", $testid, $this->arrayToDescription( $source ) ) );
} | php | public function conformance_issue( $testid, $message, $source )
{
if ( ! $this->log ) return;
$this->conformanceIssueWarning = true;
// Concatenate the key and the value
return $this->log->warning( sprintf( "[instance] $message (Section %s - %s)", $testid, $this->arrayToDescription( $source ) ) );
} | [
"public",
"function",
"conformance_issue",
"(",
"$",
"testid",
",",
"$",
"message",
",",
"$",
"source",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"log",
")",
"return",
";",
"$",
"this",
"->",
"conformanceIssueWarning",
"=",
"true",
";",
"// Concatenat... | A convenience function for logging an event about an XBRL conformance test.
It will log a message at the PEAR_LOG_DEBUG log level.
PEAR_LOG_WARNING
@param string $testid The specification section reference
@param string $message String or object containing the message to log.
@param array $source An array containing details about the source such as the element id, segment, period, etc.
@return boolean True if the message was successfully logged. | [
"A",
"convenience",
"function",
"for",
"logging",
"an",
"event",
"about",
"an",
"XBRL",
"conformance",
"test",
".",
"It",
"will",
"log",
"a",
"message",
"at",
"the",
"PEAR_LOG_DEBUG",
"log",
"level",
"."
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Log.php#L563-L569 | train |
bseddon/XBRL | Formulas/Resources/Variables/VariableSet.php | VariableSet.AddVariable | public function AddVariable( &$variable )
{
$qname = $variable->getQName()->clarkNotation();
if ( isset( $this->variablesByQName[ $qname ] ) )
{
$x = 1;
\XBRL_Log::getInstance()->formula_validation( "Variable-set", "The variable name (defined on an arc) already exists", array(
'name' => $qname->clarkNotation(),
'error' => 'xbrlve:duplicateVariableNames'
) );
return false;
}
$this->variablesByQName[ $qname ] =& $variable;
$this->variableLabelToQNameMap[ "{$variable->extendedLinkRoleUri}#{$variable->label}" ] = $qname;
return true;
} | php | public function AddVariable( &$variable )
{
$qname = $variable->getQName()->clarkNotation();
if ( isset( $this->variablesByQName[ $qname ] ) )
{
$x = 1;
\XBRL_Log::getInstance()->formula_validation( "Variable-set", "The variable name (defined on an arc) already exists", array(
'name' => $qname->clarkNotation(),
'error' => 'xbrlve:duplicateVariableNames'
) );
return false;
}
$this->variablesByQName[ $qname ] =& $variable;
$this->variableLabelToQNameMap[ "{$variable->extendedLinkRoleUri}#{$variable->label}" ] = $qname;
return true;
} | [
"public",
"function",
"AddVariable",
"(",
"&",
"$",
"variable",
")",
"{",
"$",
"qname",
"=",
"$",
"variable",
"->",
"getQName",
"(",
")",
"->",
"clarkNotation",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"variablesByQName",
"[",
"$",
... | Add a variable, check for duplicates and update the lable -> qname map
@param Variable $variable (reference)
@return false; | [
"Add",
"a",
"variable",
"check",
"for",
"duplicates",
"and",
"update",
"the",
"lable",
"-",
">",
"qname",
"map"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/Formulas/Resources/Variables/VariableSet.php#L302-L319 | train |
bseddon/XBRL | Formulas/Resources/Variables/VariableSet.php | VariableSet.getParametersAsVars | public function getParametersAsVars( $vars = array() )
{
foreach ( $this->parameters as $qname => $parameter )
{
$vars[ $qname ] = $parameter->result;
}
return $vars;
} | php | public function getParametersAsVars( $vars = array() )
{
foreach ( $this->parameters as $qname => $parameter )
{
$vars[ $qname ] = $parameter->result;
}
return $vars;
} | [
"public",
"function",
"getParametersAsVars",
"(",
"$",
"vars",
"=",
"array",
"(",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"parameters",
"as",
"$",
"qname",
"=>",
"$",
"parameter",
")",
"{",
"$",
"vars",
"[",
"$",
"qname",
"]",
"=",
"$",
"... | Return an array of parameter values
@param array $vars (optional) An array of existing vars
@return array | [
"Return",
"an",
"array",
"of",
"parameter",
"values"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/Formulas/Resources/Variables/VariableSet.php#L531-L539 | train |
bseddon/XBRL | Formulas/Resources/Variables/VariableSet.php | VariableSet.getBindingsAsVars | public function getBindingsAsVars( $vars = array() )
{
// $vars = array_merge( $existingVars, $this->parameters );
$vars = $this->getParametersAsVars( $vars );
foreach( $this->factVariableBindings as $bindingQName => /** @var \XBRL\Formulas\factVariableBinding $varBinding */ $varBinding )
{
if ( $varBinding->isFallback )
{
$current = $varBinding->yieldedFact;
}
else
{
// Using current makes sure the fact is set and the binding variables are correct
if ( ! $varBinding->valid() ) $varBinding->rewind();
$current = $varBinding->current();
}
if ( $current instanceof XPath2NodeIterator ) $current->Reset();
$vars[ $bindingQName ] = $current;
$vars = array_merge( $vars, $varBinding->getAdditionalVars() );
}
foreach( $this->generalVariableBindings as $bindingQName => /** @var VariableBinding $varBinding */ $varBinding )
{
// Using current makes sure the fact is set and the binding variables are correct
// $vars[ $bindingQName ] = $this->variablesByQName[ $bindingQName ]->bindAsSequence ? $varBinding->facts : $varBinding->current();
if ( ! $varBinding->valid() ) $varBinding->rewind();
$current = $varBinding->current();
if ( $current instanceof XPath2NodeIterator )
{
// BMS 2018-04-04 Test 0023 V-03 fails because the vars are being reset presumably because a var is not a clone
$current = $current->CloneInstance();
$current->Reset();
}
else if ( $current instanceof XPathNavigator)
{
$current = $current->CloneInstance();
}
$vars[ $bindingQName ] = $current;
}
return $vars;
} | php | public function getBindingsAsVars( $vars = array() )
{
// $vars = array_merge( $existingVars, $this->parameters );
$vars = $this->getParametersAsVars( $vars );
foreach( $this->factVariableBindings as $bindingQName => /** @var \XBRL\Formulas\factVariableBinding $varBinding */ $varBinding )
{
if ( $varBinding->isFallback )
{
$current = $varBinding->yieldedFact;
}
else
{
// Using current makes sure the fact is set and the binding variables are correct
if ( ! $varBinding->valid() ) $varBinding->rewind();
$current = $varBinding->current();
}
if ( $current instanceof XPath2NodeIterator ) $current->Reset();
$vars[ $bindingQName ] = $current;
$vars = array_merge( $vars, $varBinding->getAdditionalVars() );
}
foreach( $this->generalVariableBindings as $bindingQName => /** @var VariableBinding $varBinding */ $varBinding )
{
// Using current makes sure the fact is set and the binding variables are correct
// $vars[ $bindingQName ] = $this->variablesByQName[ $bindingQName ]->bindAsSequence ? $varBinding->facts : $varBinding->current();
if ( ! $varBinding->valid() ) $varBinding->rewind();
$current = $varBinding->current();
if ( $current instanceof XPath2NodeIterator )
{
// BMS 2018-04-04 Test 0023 V-03 fails because the vars are being reset presumably because a var is not a clone
$current = $current->CloneInstance();
$current->Reset();
}
else if ( $current instanceof XPathNavigator)
{
$current = $current->CloneInstance();
}
$vars[ $bindingQName ] = $current;
}
return $vars;
} | [
"public",
"function",
"getBindingsAsVars",
"(",
"$",
"vars",
"=",
"array",
"(",
")",
")",
"{",
"// $vars = array_merge( $existingVars, $this->parameters );\r",
"$",
"vars",
"=",
"$",
"this",
"->",
"getParametersAsVars",
"(",
"$",
"vars",
")",
";",
"foreach",
"(",
... | Return an array of bound facts and parameters after the evaluation
@param array $vars (optional) An array of existing vars
@return array | [
"Return",
"an",
"array",
"of",
"bound",
"facts",
"and",
"parameters",
"after",
"the",
"evaluation"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/Formulas/Resources/Variables/VariableSet.php#L546-L588 | train |
bseddon/XBRL | Formulas/Resources/Variables/VariableSet.php | VariableSet.getFactsWithNils | public function getFactsWithNils()
{
if ( $this->nilsFactsCache )
{
return $this->nilsFactsCache;
}
else
{
$nilsFactsCacheExpression = "xfi:facts-in-instance(/xbrli:xbrl)";
if ( ! is_null( $this->groupFilterExpression ) )
{
$nilsFactsCacheExpression .= "[{$this->groupFilterExpression}]";
}
// Because this is the first time the facts have been accessed there are only parameters to be used as variables
$this->nilsFactsCache = BufferedNodeIterator::fromSourceWithClone( $this->evaluateXPath( $this, $nilsFactsCacheExpression, $this->parameters ), false );
// $this->nilsFactsCache = $this->evaluateXPath( $this, $nilsFactsCacheExpression, $this->parameters );
return $this->nilsFactsCache; // ->CloneInstance();
}
} | php | public function getFactsWithNils()
{
if ( $this->nilsFactsCache )
{
return $this->nilsFactsCache;
}
else
{
$nilsFactsCacheExpression = "xfi:facts-in-instance(/xbrli:xbrl)";
if ( ! is_null( $this->groupFilterExpression ) )
{
$nilsFactsCacheExpression .= "[{$this->groupFilterExpression}]";
}
// Because this is the first time the facts have been accessed there are only parameters to be used as variables
$this->nilsFactsCache = BufferedNodeIterator::fromSourceWithClone( $this->evaluateXPath( $this, $nilsFactsCacheExpression, $this->parameters ), false );
// $this->nilsFactsCache = $this->evaluateXPath( $this, $nilsFactsCacheExpression, $this->parameters );
return $this->nilsFactsCache; // ->CloneInstance();
}
} | [
"public",
"function",
"getFactsWithNils",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"nilsFactsCache",
")",
"{",
"return",
"$",
"this",
"->",
"nilsFactsCache",
";",
"}",
"else",
"{",
"$",
"nilsFactsCacheExpression",
"=",
"\"xfi:facts-in-instance(/xbrli:xbrl)\"",... | Return a list of the input instance fact with nils
@return \lyquidity\XPath2\XPath2NodeIterator | [
"Return",
"a",
"list",
"of",
"the",
"input",
"instance",
"fact",
"with",
"nils"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/Formulas/Resources/Variables/VariableSet.php#L632-L651 | train |
bseddon/XBRL | Formulas/Resources/Variables/VariableSet.php | VariableSet.setFactsDimensions | public function setFactsDimensions( $nils, $dimensions )
{
if ( $nils )
$this->nilFactsDimensions = $dimensions;
else
$this->factsDimensions = $dimensions;
} | php | public function setFactsDimensions( $nils, $dimensions )
{
if ( $nils )
$this->nilFactsDimensions = $dimensions;
else
$this->factsDimensions = $dimensions;
} | [
"public",
"function",
"setFactsDimensions",
"(",
"$",
"nils",
",",
"$",
"dimensions",
")",
"{",
"if",
"(",
"$",
"nils",
")",
"$",
"this",
"->",
"nilFactsDimensions",
"=",
"$",
"dimensions",
";",
"else",
"$",
"this",
"->",
"factsDimensions",
"=",
"$",
"di... | Set a list of the dimensions across all dimensions
@param bool $nils
@param array $dimensions
@return array[\QName]|null | [
"Set",
"a",
"list",
"of",
"the",
"dimensions",
"across",
"all",
"dimensions"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/Formulas/Resources/Variables/VariableSet.php#L681-L687 | train |
bseddon/XBRL | Formulas/Resources/Variables/VariableSet.php | VariableSet.getFactsWithoutNils | public function getFactsWithoutNils()
{
if ( $this->nonNilsFactsCache )
{
return $this->nonNilsFactsCache;
}
else
{
$nonNilsFactsCacheExpression = "xfi:non-nil-facts-in-instance(/xbrli:xbrl)";
if ( ! is_null( $this->groupFilterExpression ) )
{
$nonNilsFactsCacheExpression .= "[{$this->groupFilterExpression}]";
}
// Because this is the first time the facts have been accessed there are only parameters to be used as variables
$this->nonNilsFactsCache = BufferedNodeIterator::fromSourceWithClone( $this->evaluateXPath( $this, $nonNilsFactsCacheExpression, $this->parameters ), false );
// $this->nonNilsFactsCache = $this->evaluateXPath( $this, $nonNilsFactsCacheExpression, $this->parameters );
return $this->nonNilsFactsCache; //->CloneInstance();
}
} | php | public function getFactsWithoutNils()
{
if ( $this->nonNilsFactsCache )
{
return $this->nonNilsFactsCache;
}
else
{
$nonNilsFactsCacheExpression = "xfi:non-nil-facts-in-instance(/xbrli:xbrl)";
if ( ! is_null( $this->groupFilterExpression ) )
{
$nonNilsFactsCacheExpression .= "[{$this->groupFilterExpression}]";
}
// Because this is the first time the facts have been accessed there are only parameters to be used as variables
$this->nonNilsFactsCache = BufferedNodeIterator::fromSourceWithClone( $this->evaluateXPath( $this, $nonNilsFactsCacheExpression, $this->parameters ), false );
// $this->nonNilsFactsCache = $this->evaluateXPath( $this, $nonNilsFactsCacheExpression, $this->parameters );
return $this->nonNilsFactsCache; //->CloneInstance();
}
} | [
"public",
"function",
"getFactsWithoutNils",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"nonNilsFactsCache",
")",
"{",
"return",
"$",
"this",
"->",
"nonNilsFactsCache",
";",
"}",
"else",
"{",
"$",
"nonNilsFactsCacheExpression",
"=",
"\"xfi:non-nil-facts-in-insta... | Return a list of the input instance fact withou nils
@return \lyquidity\XPath2\XPath2NodeIterator | [
"Return",
"a",
"list",
"of",
"the",
"input",
"instance",
"fact",
"withou",
"nils"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/Formulas/Resources/Variables/VariableSet.php#L693-L712 | train |
bseddon/XBRL | Formulas/Resources/Variables/VariableSet.php | VariableSet.getVariableDetails | public function getVariableDetails( $variable, $includePrefix = true )
{
$result = array( 'value' => $this->valueToString( $variable, $includePrefix ) );
if ( $variable instanceof DOMXPathNavigator )
{
$result['concept'] = $variable->getName();
$result['context'] = FactValues::getContextRef( $variable );
$result['unit'] = FactValues::getUnitRef( $variable );
}
return $result;
} | php | public function getVariableDetails( $variable, $includePrefix = true )
{
$result = array( 'value' => $this->valueToString( $variable, $includePrefix ) );
if ( $variable instanceof DOMXPathNavigator )
{
$result['concept'] = $variable->getName();
$result['context'] = FactValues::getContextRef( $variable );
$result['unit'] = FactValues::getUnitRef( $variable );
}
return $result;
} | [
"public",
"function",
"getVariableDetails",
"(",
"$",
"variable",
",",
"$",
"includePrefix",
"=",
"true",
")",
"{",
"$",
"result",
"=",
"array",
"(",
"'value'",
"=>",
"$",
"this",
"->",
"valueToString",
"(",
"$",
"variable",
",",
"$",
"includePrefix",
")",... | Returns a set of details for a fact
@param DOMXPathNavigator|XPathItem $fact
@param bool $includePrefix (default: true) When true a prefix indicating the type of value will be included
@return array | [
"Returns",
"a",
"set",
"of",
"details",
"for",
"a",
"fact"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/Formulas/Resources/Variables/VariableSet.php#L720-L731 | train |
bseddon/XBRL | Formulas/Resources/Variables/VariableSet.php | VariableSet.createDefaultMessage | public function createDefaultMessage( $test, $vars )
{
$substitutions = array();
// Look for variables in the test
foreach ( $vars as $name => $var )
{
if ( strpos( $test, "\$$name") === false ) continue;
$substitutions[ $name ] = Resource::valueToString( $var );
}
foreach ( $substitutions as $name => $substitution )
{
$test = preg_replace('/\b' . $name . '\b/', "$name $substitution", $test);
// $test = str_replace( $name, $name . " " . $substitution, $test );
}
return $test;
} | php | public function createDefaultMessage( $test, $vars )
{
$substitutions = array();
// Look for variables in the test
foreach ( $vars as $name => $var )
{
if ( strpos( $test, "\$$name") === false ) continue;
$substitutions[ $name ] = Resource::valueToString( $var );
}
foreach ( $substitutions as $name => $substitution )
{
$test = preg_replace('/\b' . $name . '\b/', "$name $substitution", $test);
// $test = str_replace( $name, $name . " " . $substitution, $test );
}
return $test;
} | [
"public",
"function",
"createDefaultMessage",
"(",
"$",
"test",
",",
"$",
"vars",
")",
"{",
"$",
"substitutions",
"=",
"array",
"(",
")",
";",
"// Look for variables in the test\r",
"foreach",
"(",
"$",
"vars",
"as",
"$",
"name",
"=>",
"$",
"var",
")",
"{"... | Generates a default message based on the formula test
@param string $test The test on which to base the default message
@param array $vars
@return mixed[] | [
"Generates",
"a",
"default",
"message",
"based",
"on",
"the",
"formula",
"test"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/Formulas/Resources/Variables/VariableSet.php#L739-L758 | train |
bseddon/XBRL | XBRL-Formulas.php | XBRL_Formulas.validateCommon | private function validateCommon( $taxonomy, $contextParameters )
{
// if ( ! $this->validateParameters( $taxonomy, $contextParameters ) )
// {
// return false;
// }
if ( ! $this->validateCustomFunction( $taxonomy ) )
{
return false;
}
if ( ! $this->validateVariableSets( $taxonomy, $contextParameters ) )
{
return false;
}
if ( ! $this->validateConsistencyAssertions( $taxonomy ) )
{
return false;
}
// validate default dimensions in instances and accumulate multi-instance-default dimension aspects (really, look in the contexts)
// check for variable set dependencies across output instances produced
return true;
} | php | private function validateCommon( $taxonomy, $contextParameters )
{
// if ( ! $this->validateParameters( $taxonomy, $contextParameters ) )
// {
// return false;
// }
if ( ! $this->validateCustomFunction( $taxonomy ) )
{
return false;
}
if ( ! $this->validateVariableSets( $taxonomy, $contextParameters ) )
{
return false;
}
if ( ! $this->validateConsistencyAssertions( $taxonomy ) )
{
return false;
}
// validate default dimensions in instances and accumulate multi-instance-default dimension aspects (really, look in the contexts)
// check for variable set dependencies across output instances produced
return true;
} | [
"private",
"function",
"validateCommon",
"(",
"$",
"taxonomy",
",",
"$",
"contextParameters",
")",
"{",
"// if ( ! $this->validateParameters( $taxonomy, $contextParameters ) )\r",
"// {\r",
"// \treturn false;\r",
"// }\r",
"if",
"(",
"!",
"$",
"this",
"->",
"validateCustom... | Process the validations common to all variable sets
@param XBRL $taxonomy
@param array $contextParameters A list of the parameter values to be used as sources for formula parameters
@return bool | [
"Process",
"the",
"validations",
"common",
"to",
"all",
"variable",
"sets"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Formulas.php#L453-L480 | train |
bseddon/XBRL | XBRL-Formulas.php | XBRL_Formulas.addNamespaces | private function addNamespaces( $additionalNamespaces )
{
// Load any additional namespaces
foreach ( $additionalNamespaces as $namespaces )
{
if ( is_null( $namespaces ) || ! is_array( $namespaces ) )
{
continue;
}
foreach ( $namespaces as $prefix => $namespace )
{
if ( empty( $prefix ) ) continue;
$this->nsMgr->addNamespace( $prefix, $namespace );
}
}
} | php | private function addNamespaces( $additionalNamespaces )
{
// Load any additional namespaces
foreach ( $additionalNamespaces as $namespaces )
{
if ( is_null( $namespaces ) || ! is_array( $namespaces ) )
{
continue;
}
foreach ( $namespaces as $prefix => $namespace )
{
if ( empty( $prefix ) ) continue;
$this->nsMgr->addNamespace( $prefix, $namespace );
}
}
} | [
"private",
"function",
"addNamespaces",
"(",
"$",
"additionalNamespaces",
")",
"{",
"// Load any additional namespaces\r",
"foreach",
"(",
"$",
"additionalNamespaces",
"as",
"$",
"namespaces",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"namespaces",
")",
"||",
"!",... | Creates a namespace manager for a formula processor
@param array $additionalNamespaces An array of namespace arrays (which is an array of namespaces indexed by prefix) | [
"Creates",
"a",
"namespace",
"manager",
"for",
"a",
"formula",
"processor"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Formulas.php#L486-L502 | train |
bseddon/XBRL | XBRL-Formulas.php | XBRL_Formulas.validateVariableScopes | private function validateVariableScopes( $taxonomy, $variableSetInstance )
{
$scopeArcs = $taxonomy->getGenericArc( XBRL_Constants::$arcRoleVariablesScope, $variableSetInstance->extendedLinkRoleUri, null, $variableSetInstance->path, null, $variableSetInstance->linkbase );
if ( ! $scopeArcs ) return true;
// Include any scope variables referenced directly from this variable set or indirectly because
// because the variable referenced by this variable set references another variable set and so on
$label = $variableSetInstance->label;
$labels = array();
while (true)
{
$found = false;
$labels[] = $label;
foreach ( $scopeArcs as $scopeArc )
{
if ( ! isset( $scopeArc['to'] ) || $scopeArc['to'] != $label ) continue;
// This is a different kind of variable
$scopeQName = new QName( $scopeArc['name']['originalPrefix'], $scopeArc['name']['namespace'], $scopeArc['name']['name'] );
$found = true;
break;
}
if ( ! $found ) break;
if ( isset( $variableSetInstance->scopeDependencies[ $scopeQName->clarkNotation() ] ) )
{
// Cyclic relationship detected
$this->log->formula_validation( "Scope variables", "The scope variables include a cyclic dependency",
array(
'error' => 'xbrl21:directedCycleError',
'variable sets' => implode( ", ", $labels ) . ", ..."
)
);
}
$variableSetInstance->scopeDependencies[ $scopeQName->clarkNotation() ] = $scopeArc;
if ( ! isset( $scopeArc['from'] ) ) break;
$label = $scopeArc['from'];
}
// Now add any variables from the source variable set so they can be included in this variable set's validation
foreach ( $variableSetInstance->scopeDependencies as $qname => $scopeDependency )
{
$fromVariableSetKey = "{$scopeDependency['fromRoleUri']}#{$scopeDependency['from']}";
$scopeVariableInstances = $this->variableSets[ $fromVariableSetKey ];
// look for any variables
foreach ( $scopeVariableInstances as $scopeVariableInstanceKey => $scopeVariableInstance )
{
foreach ( $scopeVariableInstance->variablesByQName as $variableQName => $variable )
{
// Create a dummy variable. It will be overridden later on.
if ( isset( $variableSetInstance->variablesByQName[ $variableQName ] ) ) continue;
$variableSetInstance->variablesByQName[ $variableQName ] = new ScopeVariable();
}
}
}
return true;
} | php | private function validateVariableScopes( $taxonomy, $variableSetInstance )
{
$scopeArcs = $taxonomy->getGenericArc( XBRL_Constants::$arcRoleVariablesScope, $variableSetInstance->extendedLinkRoleUri, null, $variableSetInstance->path, null, $variableSetInstance->linkbase );
if ( ! $scopeArcs ) return true;
// Include any scope variables referenced directly from this variable set or indirectly because
// because the variable referenced by this variable set references another variable set and so on
$label = $variableSetInstance->label;
$labels = array();
while (true)
{
$found = false;
$labels[] = $label;
foreach ( $scopeArcs as $scopeArc )
{
if ( ! isset( $scopeArc['to'] ) || $scopeArc['to'] != $label ) continue;
// This is a different kind of variable
$scopeQName = new QName( $scopeArc['name']['originalPrefix'], $scopeArc['name']['namespace'], $scopeArc['name']['name'] );
$found = true;
break;
}
if ( ! $found ) break;
if ( isset( $variableSetInstance->scopeDependencies[ $scopeQName->clarkNotation() ] ) )
{
// Cyclic relationship detected
$this->log->formula_validation( "Scope variables", "The scope variables include a cyclic dependency",
array(
'error' => 'xbrl21:directedCycleError',
'variable sets' => implode( ", ", $labels ) . ", ..."
)
);
}
$variableSetInstance->scopeDependencies[ $scopeQName->clarkNotation() ] = $scopeArc;
if ( ! isset( $scopeArc['from'] ) ) break;
$label = $scopeArc['from'];
}
// Now add any variables from the source variable set so they can be included in this variable set's validation
foreach ( $variableSetInstance->scopeDependencies as $qname => $scopeDependency )
{
$fromVariableSetKey = "{$scopeDependency['fromRoleUri']}#{$scopeDependency['from']}";
$scopeVariableInstances = $this->variableSets[ $fromVariableSetKey ];
// look for any variables
foreach ( $scopeVariableInstances as $scopeVariableInstanceKey => $scopeVariableInstance )
{
foreach ( $scopeVariableInstance->variablesByQName as $variableQName => $variable )
{
// Create a dummy variable. It will be overridden later on.
if ( isset( $variableSetInstance->variablesByQName[ $variableQName ] ) ) continue;
$variableSetInstance->variablesByQName[ $variableQName ] = new ScopeVariable();
}
}
}
return true;
} | [
"private",
"function",
"validateVariableScopes",
"(",
"$",
"taxonomy",
",",
"$",
"variableSetInstance",
")",
"{",
"$",
"scopeArcs",
"=",
"$",
"taxonomy",
"->",
"getGenericArc",
"(",
"XBRL_Constants",
"::",
"$",
"arcRoleVariablesScope",
",",
"$",
"variableSetInstance... | Look for and validate any variable scope arcs
@param \XBRL $taxonomy
@param VariableSet $variableSetInstance | [
"Look",
"for",
"and",
"validate",
"any",
"variable",
"scope",
"arcs"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Formulas.php#L1352-L1411 | train |
bseddon/XBRL | XBRL-Formulas.php | XBRL_Formulas.validateLabels | private function validateLabels( $taxonomy, $target, $lang = 'en' )
{
$labelArcs = $taxonomy->getGenericArc( XBRL_Constants::$genericElementLabel, $target->extendedLinkRoleUri, $target->label, $target->path, null, $target->linkbase );
if ( ! $labelArcs ) return true;
// Find the filter resources
foreach ( $labelArcs as $labelArc )
{
if ( $labelArc['path'] != $target->path ) continue;
// TODO Handle preferred label by taking and using the preferred label role from the arc
$result = $taxonomy->getGenericLabel( XBRL_Constants::$genericRoleLabel, $labelArc['to'], substr( $lang, 0, 2 ), $target->path );
if ( ! $result ) continue;
// The should be only one but make sure by taking the first.
$textLabel = reset( $result );
$target->description = $textLabel['text'];
}
return true;
} | php | private function validateLabels( $taxonomy, $target, $lang = 'en' )
{
$labelArcs = $taxonomy->getGenericArc( XBRL_Constants::$genericElementLabel, $target->extendedLinkRoleUri, $target->label, $target->path, null, $target->linkbase );
if ( ! $labelArcs ) return true;
// Find the filter resources
foreach ( $labelArcs as $labelArc )
{
if ( $labelArc['path'] != $target->path ) continue;
// TODO Handle preferred label by taking and using the preferred label role from the arc
$result = $taxonomy->getGenericLabel( XBRL_Constants::$genericRoleLabel, $labelArc['to'], substr( $lang, 0, 2 ), $target->path );
if ( ! $result ) continue;
// The should be only one but make sure by taking the first.
$textLabel = reset( $result );
$target->description = $textLabel['text'];
}
return true;
} | [
"private",
"function",
"validateLabels",
"(",
"$",
"taxonomy",
",",
"$",
"target",
",",
"$",
"lang",
"=",
"'en'",
")",
"{",
"$",
"labelArcs",
"=",
"$",
"taxonomy",
"->",
"getGenericArc",
"(",
"XBRL_Constants",
"::",
"$",
"genericElementLabel",
",",
"$",
"t... | Add the label to a resource
@param XBRL $taxonomy
@param Variable|AssertionSet $target
@param string $lang
@return boolean | [
"Add",
"the",
"label",
"to",
"a",
"resource"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Formulas.php#L1420-L1441 | train |
bseddon/XBRL | XBRL-Formulas.php | XBRL_Formulas.validateEqualityDefinition | private function validateEqualityDefinition( $taxonomy )
{
\XBRL_Log::getInstance()->info( "Need to implement equality definition validation" );
$taxonomy->getGenericArc( XBRL_Constants::$arcRoleVariableEqualityDefinition );
return true;
} | php | private function validateEqualityDefinition( $taxonomy )
{
\XBRL_Log::getInstance()->info( "Need to implement equality definition validation" );
$taxonomy->getGenericArc( XBRL_Constants::$arcRoleVariableEqualityDefinition );
return true;
} | [
"private",
"function",
"validateEqualityDefinition",
"(",
"$",
"taxonomy",
")",
"{",
"\\",
"XBRL_Log",
"::",
"getInstance",
"(",
")",
"->",
"info",
"(",
"\"Need to implement equality definition validation\"",
")",
";",
"$",
"taxonomy",
"->",
"getGenericArc",
"(",
"X... | Process an equality definition
@param XBRL $taxonomy
@return boolean | [
"Process",
"an",
"equality",
"definition"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Formulas.php#L2000-L2005 | train |
bseddon/XBRL | XBRL-Formulas.php | XBRL_Formulas.evaluate | private function evaluate( $variableSet )
{
if ( ! $this->canEvaluate ) return;
if ( isset( $variableSet->evaluated ) ) return true;
// Process the variables in hierarchy order
// $variableSet->parameters =& $this->parameterQnames;
$variableSet->nsMgr = $this->nsMgr;
$variableSet->xbrlInstance = $this->instances[ $this->instanceQName->clarkNotation() ];
if ( $variableSet->evaluate() )
{
// If the variable set is a formula then add a facts container
if ( $variableSet instanceof Formula )
{
if ( is_null( $this->formulaFactsContainer ) ) $this->formulaFactsContainer = new GeneratedFacts();
$variableSet->factsContainer = $this->formulaFactsContainer;
}
$variableSet->ProcessEvaluationResult( $this->log );
// If the variable set is a formula recover the facts container
if ( $variableSet instanceof Formula )
{
// This is probably redundant because the container instance will be passed to the variable set by reference
$this->formulaFactsContainer = $variableSet->factsContainer;
}
}
$variableSet->evaluated = true;
return true;
} | php | private function evaluate( $variableSet )
{
if ( ! $this->canEvaluate ) return;
if ( isset( $variableSet->evaluated ) ) return true;
// Process the variables in hierarchy order
// $variableSet->parameters =& $this->parameterQnames;
$variableSet->nsMgr = $this->nsMgr;
$variableSet->xbrlInstance = $this->instances[ $this->instanceQName->clarkNotation() ];
if ( $variableSet->evaluate() )
{
// If the variable set is a formula then add a facts container
if ( $variableSet instanceof Formula )
{
if ( is_null( $this->formulaFactsContainer ) ) $this->formulaFactsContainer = new GeneratedFacts();
$variableSet->factsContainer = $this->formulaFactsContainer;
}
$variableSet->ProcessEvaluationResult( $this->log );
// If the variable set is a formula recover the facts container
if ( $variableSet instanceof Formula )
{
// This is probably redundant because the container instance will be passed to the variable set by reference
$this->formulaFactsContainer = $variableSet->factsContainer;
}
}
$variableSet->evaluated = true;
return true;
} | [
"private",
"function",
"evaluate",
"(",
"$",
"variableSet",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"canEvaluate",
")",
"return",
";",
"if",
"(",
"isset",
"(",
"$",
"variableSet",
"->",
"evaluated",
")",
")",
"return",
"true",
";",
"// Process the v... | Evaluate the formula. At the moment the instanceQNames points to the current instance being processed
@param VariableSet $variableSet
@return bool | [
"Evaluate",
"the",
"formula",
".",
"At",
"the",
"moment",
"the",
"instanceQNames",
"points",
"to",
"the",
"current",
"instance",
"being",
"processed"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Formulas.php#L2012-L2043 | train |
bseddon/XBRL | XBRL-Instance.php | XBRL_Instance.FromInstanceDocumentWithExtensionTaxonomy | public static function FromInstanceDocumentWithExtensionTaxonomy( $instance_document, $compiledLocation, $className = 'XBRL', $useCache = false )
{
try
{
$instance = new XBRL_Instance();
$instance->compiledLocation = $compiledLocation;
$instance->className = $className;
if ( ! $instance->initialise( $instance_document, null, $useCache ) )
{
return false;
}
}
catch ( FormulasException $ex)
{
throw $ex;
}
catch( Exception $ex )
{
$instance->error = "Error initialising the instance document. It may contain invalid XML.\n";
return false;
}
return $instance;
} | php | public static function FromInstanceDocumentWithExtensionTaxonomy( $instance_document, $compiledLocation, $className = 'XBRL', $useCache = false )
{
try
{
$instance = new XBRL_Instance();
$instance->compiledLocation = $compiledLocation;
$instance->className = $className;
if ( ! $instance->initialise( $instance_document, null, $useCache ) )
{
return false;
}
}
catch ( FormulasException $ex)
{
throw $ex;
}
catch( Exception $ex )
{
$instance->error = "Error initialising the instance document. It may contain invalid XML.\n";
return false;
}
return $instance;
} | [
"public",
"static",
"function",
"FromInstanceDocumentWithExtensionTaxonomy",
"(",
"$",
"instance_document",
",",
"$",
"compiledLocation",
",",
"$",
"className",
"=",
"'XBRL'",
",",
"$",
"useCache",
"=",
"false",
")",
"{",
"try",
"{",
"$",
"instance",
"=",
"new",... | Create an instance from an instance document using a base taxonomy if possible
@param string $instance_document The file containing the instance information
@param string $compiledLocation The location of compiled taxonomies
@param string $className The name of an XBRL class to initialize (defaults to 'XBRL')
@param bool $useCache (default: false) If true the instance document will be read from the cache
@return XBRL_Instance|bool | [
"Create",
"an",
"instance",
"from",
"an",
"instance",
"document",
"using",
"a",
"base",
"taxonomy",
"if",
"possible"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Instance.php#L215-L239 | train |
bseddon/XBRL | XBRL-Instance.php | XBRL_Instance.FromInstanceDocument | public static function FromInstanceDocument( $instance_document, $taxonomy_file = null, &$instance = null, $allowNested = false, $useCache = false )
{
try
{
$instance = new XBRL_Instance();
$instance->allowNested = $allowNested;
if ( ! $instance->initialise( $instance_document, $taxonomy_file, $useCache ) )
{
return false;
}
}
catch ( FormulasException $ex)
{
throw $ex;
}
catch( Exception $ex )
{
$instance->error = "Error initialising the instance document. It may contain invalid XML.\n";
return false;
}
return $instance;
} | php | public static function FromInstanceDocument( $instance_document, $taxonomy_file = null, &$instance = null, $allowNested = false, $useCache = false )
{
try
{
$instance = new XBRL_Instance();
$instance->allowNested = $allowNested;
if ( ! $instance->initialise( $instance_document, $taxonomy_file, $useCache ) )
{
return false;
}
}
catch ( FormulasException $ex)
{
throw $ex;
}
catch( Exception $ex )
{
$instance->error = "Error initialising the instance document. It may contain invalid XML.\n";
return false;
}
return $instance;
} | [
"public",
"static",
"function",
"FromInstanceDocument",
"(",
"$",
"instance_document",
",",
"$",
"taxonomy_file",
"=",
"null",
",",
"&",
"$",
"instance",
"=",
"null",
",",
"$",
"allowNested",
"=",
"false",
",",
"$",
"useCache",
"=",
"false",
")",
"{",
"try... | Create an instance from an instance document
@param string $instance_document The file containing the instance information
@param string $taxonomy_file The taxonomy for the instance document
@param XBRL_Instance &$instance A reference to the instance created by this call
@param bool $allowNested (optional: false) True if the caller wants to allow one or more <xbrl> containers to appear in a larger document
@param bool $useCache (default: false) If true the instance document will be read from the cache
@return XBRL_Instance|bool | [
"Create",
"an",
"instance",
"from",
"an",
"instance",
"document"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Instance.php#L251-L273 | train |
bseddon/XBRL | XBRL-Instance.php | XBRL_Instance.FromInstanceCache | public static function FromInstanceCache( $cache_path, $cache_basename, $taxonomyNamespace, $compiledTaxonomyFile )
{
$xbrl = XBRL::load_taxonomy( $compiledTaxonomyFile );
if ( ! $xbrl ) return false;
$json = null;
if ( XBRL::endsWith( $cache_basename, '.zip' ) )
{
$zip = new \ZipArchive();
$zip->open( "$cache_path/$cache_basename" );
$json = $zip->getFromName( basename( $cache_basename, '.zip' ) . '.json' );
}
else
{
$json = file_get_contents( "$cache_path/$cache_basename" );
}
$instance = new XBRL_Instance();
$array = json_decode( $json, true );
$instance->allowNested = $array['allowNested'];
$instance->contextDimensionMemberList = $array['contextDimensionMemberList'];
$instance->contexts = $array['contexts'];
$instance->document_name = $array['document_name'];
$instance->duplicateFacts = TupleDictionary::fromJSON( $array['duplicateFacts'] );
$instance->elements = $array['elements'];
$instance->error = $array['error'];
$instance->footnotes = $array['footnotes'];
$instance->guid = $array['guid'];
$instance->instance_namespaces = $array['instance_namespaces'];
$instance->segments = $array['segments'];
$instance->tupleRefs = $array['tupleRefs'];
$instance->uniqueFactIds = $array['uniqueFactIds'];
$instance->units = $array['units'];
$instance->usedContexts = $array['usedContexts'];
$instance->instance_xml = simplexml_load_file( $instance->document_name );
$taxonomy = $xbrl->getTaxonomyForNamespace( $taxonomyNamespace );
XBRL_Instance::$instance_taxonomy[ $taxonomy->getSchemaLocation() ] = $taxonomy;
$instance->schemaFilename = $taxonomy->getSchemaLocation();
$instance->defaultCurrency = $taxonomy->getDefaultCurrency();
$instance->taxonomyToNamespaceMap = $taxonomy->getImportedSchemas();
return $instance;
} | php | public static function FromInstanceCache( $cache_path, $cache_basename, $taxonomyNamespace, $compiledTaxonomyFile )
{
$xbrl = XBRL::load_taxonomy( $compiledTaxonomyFile );
if ( ! $xbrl ) return false;
$json = null;
if ( XBRL::endsWith( $cache_basename, '.zip' ) )
{
$zip = new \ZipArchive();
$zip->open( "$cache_path/$cache_basename" );
$json = $zip->getFromName( basename( $cache_basename, '.zip' ) . '.json' );
}
else
{
$json = file_get_contents( "$cache_path/$cache_basename" );
}
$instance = new XBRL_Instance();
$array = json_decode( $json, true );
$instance->allowNested = $array['allowNested'];
$instance->contextDimensionMemberList = $array['contextDimensionMemberList'];
$instance->contexts = $array['contexts'];
$instance->document_name = $array['document_name'];
$instance->duplicateFacts = TupleDictionary::fromJSON( $array['duplicateFacts'] );
$instance->elements = $array['elements'];
$instance->error = $array['error'];
$instance->footnotes = $array['footnotes'];
$instance->guid = $array['guid'];
$instance->instance_namespaces = $array['instance_namespaces'];
$instance->segments = $array['segments'];
$instance->tupleRefs = $array['tupleRefs'];
$instance->uniqueFactIds = $array['uniqueFactIds'];
$instance->units = $array['units'];
$instance->usedContexts = $array['usedContexts'];
$instance->instance_xml = simplexml_load_file( $instance->document_name );
$taxonomy = $xbrl->getTaxonomyForNamespace( $taxonomyNamespace );
XBRL_Instance::$instance_taxonomy[ $taxonomy->getSchemaLocation() ] = $taxonomy;
$instance->schemaFilename = $taxonomy->getSchemaLocation();
$instance->defaultCurrency = $taxonomy->getDefaultCurrency();
$instance->taxonomyToNamespaceMap = $taxonomy->getImportedSchemas();
return $instance;
} | [
"public",
"static",
"function",
"FromInstanceCache",
"(",
"$",
"cache_path",
",",
"$",
"cache_basename",
",",
"$",
"taxonomyNamespace",
",",
"$",
"compiledTaxonomyFile",
")",
"{",
"$",
"xbrl",
"=",
"XBRL",
"::",
"load_taxonomy",
"(",
"$",
"compiledTaxonomyFile",
... | Creates an instance object from a JSON string, perhaps in a zip file
@param string $cache_path
@param string $cache_basename
@param string $taxonomyNamespace
@param string $compiledTaxonomyFile
@return XBRL_Instance | [
"Creates",
"an",
"instance",
"object",
"from",
"a",
"JSON",
"string",
"perhaps",
"in",
"a",
"zip",
"file"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Instance.php#L283-L329 | train |
bseddon/XBRL | XBRL-Instance.php | XBRL_Instance.toInstanceCache | public function toInstanceCache( $output_path, $output_basename )
{
$json = json_encode( array(
// 'instance_taxonomy' => $this->instance_taxonomy,
'allowNested' => $this->allowNested,
// 'cacheContextElements' => $this->cacheContextElements,
// 'cacheDocumentNamespaces' => $this->cacheDocumentNamespaces,
// 'cacheNamespaces' => $this->cacheNamespaces,
'contextDimensionMemberList' => $this->contextDimensionMemberList,
'contexts' => $this->contexts,
// 'defaultCurrency' => $this->defaultCurrency,
'document_name' => $this->document_name,
'duplicateFacts' => $this->duplicateFacts->toJSON(),
'elements' => $this->elements,
'error' => $this->error,
'footnotes' => $this->footnotes,
'guid' => $this->guid,
'instance_namespaces' => $this->instance_namespaces,
// 'instance_xml' => $this->instance_xml,
// 'schemaFilename' => $this->schemaFilename,
'segments' => $this->segments,
// 'taxonomyToNamespaceMap' => array_keys( $this->taxonomyToNamespaceMap ),
'tupleRefs' => $this->tupleRefs,
'uniqueFactIds' => $this->uniqueFactIds,
'units' => $this->units,
'usedContexts' => $this->usedContexts,
) );
file_put_contents( "$output_path/$output_basename.json", $json );
$zip = new ZipArchive();
$zip->open( "$output_path/$output_basename.zip", ZipArchive::CREATE | ZipArchive::OVERWRITE );
$zip->addFile( "$output_path/$output_basename.json", "$output_basename.json" );
if ( $zip->close() === false )
{
XBRL_Log::getInstance()->err( "Error closing zip file" );
XBRL_Log::getInstance()->err( $zip->getStatusString() );
}
} | php | public function toInstanceCache( $output_path, $output_basename )
{
$json = json_encode( array(
// 'instance_taxonomy' => $this->instance_taxonomy,
'allowNested' => $this->allowNested,
// 'cacheContextElements' => $this->cacheContextElements,
// 'cacheDocumentNamespaces' => $this->cacheDocumentNamespaces,
// 'cacheNamespaces' => $this->cacheNamespaces,
'contextDimensionMemberList' => $this->contextDimensionMemberList,
'contexts' => $this->contexts,
// 'defaultCurrency' => $this->defaultCurrency,
'document_name' => $this->document_name,
'duplicateFacts' => $this->duplicateFacts->toJSON(),
'elements' => $this->elements,
'error' => $this->error,
'footnotes' => $this->footnotes,
'guid' => $this->guid,
'instance_namespaces' => $this->instance_namespaces,
// 'instance_xml' => $this->instance_xml,
// 'schemaFilename' => $this->schemaFilename,
'segments' => $this->segments,
// 'taxonomyToNamespaceMap' => array_keys( $this->taxonomyToNamespaceMap ),
'tupleRefs' => $this->tupleRefs,
'uniqueFactIds' => $this->uniqueFactIds,
'units' => $this->units,
'usedContexts' => $this->usedContexts,
) );
file_put_contents( "$output_path/$output_basename.json", $json );
$zip = new ZipArchive();
$zip->open( "$output_path/$output_basename.zip", ZipArchive::CREATE | ZipArchive::OVERWRITE );
$zip->addFile( "$output_path/$output_basename.json", "$output_basename.json" );
if ( $zip->close() === false )
{
XBRL_Log::getInstance()->err( "Error closing zip file" );
XBRL_Log::getInstance()->err( $zip->getStatusString() );
}
} | [
"public",
"function",
"toInstanceCache",
"(",
"$",
"output_path",
",",
"$",
"output_basename",
")",
"{",
"$",
"json",
"=",
"json_encode",
"(",
"array",
"(",
"// 'instance_taxonomy' => $this->instance_taxonomy,\r",
"'allowNested'",
"=>",
"$",
"this",
"->",
"allowNested... | Perist an instance to a file containing a JSON representation
@param string $output_path
@param string $output_basename
@return bool | [
"Perist",
"an",
"instance",
"to",
"a",
"file",
"containing",
"a",
"JSON",
"representation"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Instance.php#L337-L376 | train |
bseddon/XBRL | XBRL-Instance.php | XBRL_Instance.reset | public static function reset( $resetGlobal = true )
{
XBRL_Instance::$instance_taxonomy = array();
if ( ! $resetGlobal ) return;
XBRL_Global::reset();
XBRL_Types::reset();
} | php | public static function reset( $resetGlobal = true )
{
XBRL_Instance::$instance_taxonomy = array();
if ( ! $resetGlobal ) return;
XBRL_Global::reset();
XBRL_Types::reset();
} | [
"public",
"static",
"function",
"reset",
"(",
"$",
"resetGlobal",
"=",
"true",
")",
"{",
"XBRL_Instance",
"::",
"$",
"instance_taxonomy",
"=",
"array",
"(",
")",
";",
"if",
"(",
"!",
"$",
"resetGlobal",
")",
"return",
";",
"XBRL_Global",
"::",
"reset",
"... | Resets the lists of existing instance taxonomies
@param string $resetGlobal | [
"Resets",
"the",
"lists",
"of",
"existing",
"instance",
"taxonomies"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Instance.php#L392-L398 | train |
bseddon/XBRL | XBRL-Instance.php | XBRL_Instance.getEntityForElement | public function getEntityForElement( $element )
{
if ( isset( $element['contextRef'] ) )
{
return $this->contexts[ $element['contextRef'] ]['entity']['identifier']['value'];
}
if ( isset( $element['tuple_elements'] ) )
{
foreach ( $element['tuple_elements'] as $elementKey => $tuple_elements )
{
foreach ( $tuple_elements as $tupleIndex => $tuple_element )
{
$result = $this->getEntityForElement( $tuple_element );
if ( $result ) return $result;
}
}
}
throw new Exception( "The element '{$element['taxonomy_element']['id']}' has no context ref but also has no tuple members (getEntityForElement)" );
} | php | public function getEntityForElement( $element )
{
if ( isset( $element['contextRef'] ) )
{
return $this->contexts[ $element['contextRef'] ]['entity']['identifier']['value'];
}
if ( isset( $element['tuple_elements'] ) )
{
foreach ( $element['tuple_elements'] as $elementKey => $tuple_elements )
{
foreach ( $tuple_elements as $tupleIndex => $tuple_element )
{
$result = $this->getEntityForElement( $tuple_element );
if ( $result ) return $result;
}
}
}
throw new Exception( "The element '{$element['taxonomy_element']['id']}' has no context ref but also has no tuple members (getEntityForElement)" );
} | [
"public",
"function",
"getEntityForElement",
"(",
"$",
"element",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"element",
"[",
"'contextRef'",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"contexts",
"[",
"$",
"element",
"[",
"'contextRef'",
"]",
"]",
"... | Get the entity of the element. For a simple concept this is easy but for a tuple its necessary to look at the tuple elements
@param array $element
@return string The entity of the element | [
"Get",
"the",
"entity",
"of",
"the",
"element",
".",
"For",
"a",
"simple",
"concept",
"this",
"is",
"easy",
"but",
"for",
"a",
"tuple",
"its",
"necessary",
"to",
"look",
"at",
"the",
"tuple",
"elements"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Instance.php#L414-L434 | train |
bseddon/XBRL | XBRL-Instance.php | XBRL_Instance.getContext | public function getContext( $id )
{
return isset( $this->contexts[ $id ] ) ? $this->contexts[ $id ] : null;
} | php | public function getContext( $id )
{
return isset( $this->contexts[ $id ] ) ? $this->contexts[ $id ] : null;
} | [
"public",
"function",
"getContext",
"(",
"$",
"id",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"contexts",
"[",
"$",
"id",
"]",
")",
"?",
"$",
"this",
"->",
"contexts",
"[",
"$",
"id",
"]",
":",
"null",
";",
"}"
] | Get a specific context
@param string $id The id of the context to retrieve
@return array|null | [
"Get",
"a",
"specific",
"context"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Instance.php#L545-L548 | train |
bseddon/XBRL | XBRL-Instance.php | XBRL_Instance.hasDimension | public function hasDimension( $contextRef, $dimension, $includeDefault = false )
{
if ( ! isset( $this->contexts[ $contextRef ] ) )
{
return false;
}
$paths = array(
array( 'entity', 'segment' ),
array( 'scenario' ),
array( 'entity', 'scenario' ),
array( 'segment' ),
);
foreach ( $paths as $path )
{
$context = $this->contexts[ $contextRef ];
foreach ( $path as $element )
{
if ( ! isset( $context[ $element ] ) ) continue 2;
$context = $context[ $element ];
}
if ( isset( $context['explicitMember'] ) )
{
foreach ( $context['explicitMember'] as $dimensionDefinition )
{
if ( $dimensionDefinition['dimension'] == $dimension ) return true;
}
}
if ( isset( $context['typedMember'] ) )
{
foreach ( $context['typedMember'] as $dimensionDefinition )
{
if ( $dimensionDefinition['dimension'] == $dimension ) return true;
}
}
}
return false;
} | php | public function hasDimension( $contextRef, $dimension, $includeDefault = false )
{
if ( ! isset( $this->contexts[ $contextRef ] ) )
{
return false;
}
$paths = array(
array( 'entity', 'segment' ),
array( 'scenario' ),
array( 'entity', 'scenario' ),
array( 'segment' ),
);
foreach ( $paths as $path )
{
$context = $this->contexts[ $contextRef ];
foreach ( $path as $element )
{
if ( ! isset( $context[ $element ] ) ) continue 2;
$context = $context[ $element ];
}
if ( isset( $context['explicitMember'] ) )
{
foreach ( $context['explicitMember'] as $dimensionDefinition )
{
if ( $dimensionDefinition['dimension'] == $dimension ) return true;
}
}
if ( isset( $context['typedMember'] ) )
{
foreach ( $context['typedMember'] as $dimensionDefinition )
{
if ( $dimensionDefinition['dimension'] == $dimension ) return true;
}
}
}
return false;
} | [
"public",
"function",
"hasDimension",
"(",
"$",
"contextRef",
",",
"$",
"dimension",
",",
"$",
"includeDefault",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"contexts",
"[",
"$",
"contextRef",
"]",
")",
")",
"{",
"return",
... | Returns true if the dimension reference can be found in a segment or scenario
@param string $contextRef
@param string $dimension
@param boolean $includeDefault
@return boolean | [
"Returns",
"true",
"if",
"the",
"dimension",
"reference",
"can",
"be",
"found",
"in",
"a",
"segment",
"or",
"scenario"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Instance.php#L557-L598 | train |
bseddon/XBRL | XBRL-Instance.php | XBRL_Instance.getUnit | public function getUnit( $id )
{
return isset( $this->units[ $id ] ) ? $this->units[ $id ] : null;
} | php | public function getUnit( $id )
{
return isset( $this->units[ $id ] ) ? $this->units[ $id ] : null;
} | [
"public",
"function",
"getUnit",
"(",
"$",
"id",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"units",
"[",
"$",
"id",
"]",
")",
"?",
"$",
"this",
"->",
"units",
"[",
"$",
"id",
"]",
":",
"null",
";",
"}"
] | Get a specific unit
@param string $id The id of the unit to retrieve
@return string|null | [
"Get",
"a",
"specific",
"unit"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Instance.php#L660-L663 | train |
bseddon/XBRL | XBRL-Instance.php | XBRL_Instance.getElement | public function getElement( $id )
{
$result = array();
if ( isset( $this->elements[ $id ] ) )
{
foreach ( $this->elements[ $id ] as $key => &$element )
{
if ( isset( $element['parent'] ) ) continue;
$element['parent'] = 'xbrl';
}
unset( $element );
$result = $this->elements[ $id ];
}
if ( ! isset( $this->tupleRefs[ $id ] ) )
{
return $result;
}
// The rest of this needs sorting
$tuple = $this->tupleRefs[ $id ];
$tupleId = key( $tuple );
if ( ! isset( $this->elements[ $tupleId ] ) )
{
return $result;
}
// $fact = array();
foreach ( $tuple[ $tupleId ] as $index )
{
foreach ( $this->elements[ $tupleId ][ $index ]['tuple_elements'][ $id ] as $key => $entry )
{
if ( ! isset( $entry['tupleid'] ) )
{
$entry['tupleid'] = $tupleId;
}
$result[ $entry['guid'] ] = $entry;
}
}
return $result;
} | php | public function getElement( $id )
{
$result = array();
if ( isset( $this->elements[ $id ] ) )
{
foreach ( $this->elements[ $id ] as $key => &$element )
{
if ( isset( $element['parent'] ) ) continue;
$element['parent'] = 'xbrl';
}
unset( $element );
$result = $this->elements[ $id ];
}
if ( ! isset( $this->tupleRefs[ $id ] ) )
{
return $result;
}
// The rest of this needs sorting
$tuple = $this->tupleRefs[ $id ];
$tupleId = key( $tuple );
if ( ! isset( $this->elements[ $tupleId ] ) )
{
return $result;
}
// $fact = array();
foreach ( $tuple[ $tupleId ] as $index )
{
foreach ( $this->elements[ $tupleId ][ $index ]['tuple_elements'][ $id ] as $key => $entry )
{
if ( ! isset( $entry['tupleid'] ) )
{
$entry['tupleid'] = $tupleId;
}
$result[ $entry['guid'] ] = $entry;
}
}
return $result;
} | [
"public",
"function",
"getElement",
"(",
"$",
"id",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"elements",
"[",
"$",
"id",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"elements",
... | Get a specific element
@param string $id The id of the element to retrieve
@return string|null | [
"Get",
"a",
"specific",
"element"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Instance.php#L670-L714 | train |
bseddon/XBRL | XBRL-Instance.php | XBRL_Instance.getPrefixForDocumentNamespace | public function getPrefixForDocumentNamespace( $namespace )
{
if ( is_null( $this->cacheDocumentNamespaces ) )
{
$this->cacheDocumentNamespaces = array_flip( $this->instance_xml->getDocNamespaces() );
// If the default namespace is one of the standards ones then the prefix may be missing
$standardNamespaces = array_flip( XBRL_Constants::$standardPrefixes );
$docNamespace = array_search( '', $this->cacheDocumentNamespaces );
if ( $docNamespace )
{
if ( isset( $standardNamespaces[ $docNamespace ] ) )
{
$this->cacheDocumentNamespaces[ $docNamespace ] = $standardNamespaces[ $docNamespace ];
}
else
{
// Get the namespace for the respective namespace
$taxonomy = $this->getInstanceTaxonomy()->getTaxonomyForNamespace( $docNamespace );
if ( $taxonomy )
{
$this->cacheDocumentNamespaces[ $docNamespace ] = $taxonomy->getPrefix();
}
}
}
}
return isset( $this->cacheDocumentNamespaces[ $namespace ] )
? $this->cacheDocumentNamespaces[ $namespace ]
: false;
} | php | public function getPrefixForDocumentNamespace( $namespace )
{
if ( is_null( $this->cacheDocumentNamespaces ) )
{
$this->cacheDocumentNamespaces = array_flip( $this->instance_xml->getDocNamespaces() );
// If the default namespace is one of the standards ones then the prefix may be missing
$standardNamespaces = array_flip( XBRL_Constants::$standardPrefixes );
$docNamespace = array_search( '', $this->cacheDocumentNamespaces );
if ( $docNamespace )
{
if ( isset( $standardNamespaces[ $docNamespace ] ) )
{
$this->cacheDocumentNamespaces[ $docNamespace ] = $standardNamespaces[ $docNamespace ];
}
else
{
// Get the namespace for the respective namespace
$taxonomy = $this->getInstanceTaxonomy()->getTaxonomyForNamespace( $docNamespace );
if ( $taxonomy )
{
$this->cacheDocumentNamespaces[ $docNamespace ] = $taxonomy->getPrefix();
}
}
}
}
return isset( $this->cacheDocumentNamespaces[ $namespace ] )
? $this->cacheDocumentNamespaces[ $namespace ]
: false;
} | [
"public",
"function",
"getPrefixForDocumentNamespace",
"(",
"$",
"namespace",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"cacheDocumentNamespaces",
")",
")",
"{",
"$",
"this",
"->",
"cacheDocumentNamespaces",
"=",
"array_flip",
"(",
"$",
"this",
"... | Returns a prefix for an xbrlInstance namespace
This only looks at the namespaces in the root of the instance dopcument
@param string $namespace | [
"Returns",
"a",
"prefix",
"for",
"an",
"xbrlInstance",
"namespace",
"This",
"only",
"looks",
"at",
"the",
"namespaces",
"in",
"the",
"root",
"of",
"the",
"instance",
"dopcument"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Instance.php#L738-L767 | train |
bseddon/XBRL | XBRL-Instance.php | XBRL_Instance.getPrefixForNamespace | public function getPrefixForNamespace( $namespace )
{
if (
! isset( $this->cacheNamespaces ) ||
count( $this->cacheNamespaces ) != count( $this->instance_namespaces )
)
{
$this->cacheNamespaces = array_flip( $this->instance_namespaces );
// If the default namespace is one of the standards ones then the prefix may be missing
$standardNamespaces = array_flip( XBRL_Constants::$standardPrefixes );
if ( isset( $this->instance_namespaces[''] ) )
{
if ( isset( $standardNamespaces[ $this->instance_namespaces[''] ] ) )
{
$this->cacheNamespaces[ $this->instance_namespaces[''] ] = $standardNamespaces[ $this->instance_namespaces[''] ];
}
}
}
return isset( $this->cacheNamespaces[ $namespace ] )
? $this->cacheNamespaces[ $namespace ]
: false;
} | php | public function getPrefixForNamespace( $namespace )
{
if (
! isset( $this->cacheNamespaces ) ||
count( $this->cacheNamespaces ) != count( $this->instance_namespaces )
)
{
$this->cacheNamespaces = array_flip( $this->instance_namespaces );
// If the default namespace is one of the standards ones then the prefix may be missing
$standardNamespaces = array_flip( XBRL_Constants::$standardPrefixes );
if ( isset( $this->instance_namespaces[''] ) )
{
if ( isset( $standardNamespaces[ $this->instance_namespaces[''] ] ) )
{
$this->cacheNamespaces[ $this->instance_namespaces[''] ] = $standardNamespaces[ $this->instance_namespaces[''] ];
}
}
}
return isset( $this->cacheNamespaces[ $namespace ] )
? $this->cacheNamespaces[ $namespace ]
: false;
} | [
"public",
"function",
"getPrefixForNamespace",
"(",
"$",
"namespace",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"cacheNamespaces",
")",
"||",
"count",
"(",
"$",
"this",
"->",
"cacheNamespaces",
")",
"!=",
"count",
"(",
"$",
"this",
"->",... | Get the prefix of a namespace
@param string $namespace
@return string|false Will return the prefix or false if one does not exist | [
"Get",
"the",
"prefix",
"of",
"a",
"namespace"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Instance.php#L781-L803 | train |
bseddon/XBRL | XBRL-Instance.php | XBRL_Instance.& | private function &getEntryForGuid( $guid )
{
if ( ! isset( $this->uniqueFactIds[ $guid ] ) )
{
return false;
}
// Get the element
$facts = $this->getElement( $this->uniqueFactIds[ $guid ] );
// And find the entry with the corresponding guid
foreach ( $facts as $key => &$entry )
{
if ( $entry['guid'] == $guid ) return $entry;
}
return false;
} | php | private function &getEntryForGuid( $guid )
{
if ( ! isset( $this->uniqueFactIds[ $guid ] ) )
{
return false;
}
// Get the element
$facts = $this->getElement( $this->uniqueFactIds[ $guid ] );
// And find the entry with the corresponding guid
foreach ( $facts as $key => &$entry )
{
if ( $entry['guid'] == $guid ) return $entry;
}
return false;
} | [
"private",
"function",
"&",
"getEntryForGuid",
"(",
"$",
"guid",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"uniqueFactIds",
"[",
"$",
"guid",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"// Get the element\r",
"$",
"facts",
"=",
... | Returns an entry for a guid or false
@param string $guid
@return array|false | [
"Returns",
"an",
"entry",
"for",
"a",
"guid",
"or",
"false"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Instance.php#L838-L855 | train |
bseddon/XBRL | XBRL-Instance.php | XBRL_Instance.normalizePrefix | private function normalizePrefix( $localPrefix )
{
if ( $localPrefix == 'xml' )
return $localPrefix;
$namespace = $this->getInstanceNamespaces()[ $localPrefix ];
$taxonomy = $this->getInstanceTaxonomy()->getTaxonomyForNamespace( $namespace );
return $taxonomy
? $taxonomy->getPrefix()
: $localPrefix;
} | php | private function normalizePrefix( $localPrefix )
{
if ( $localPrefix == 'xml' )
return $localPrefix;
$namespace = $this->getInstanceNamespaces()[ $localPrefix ];
$taxonomy = $this->getInstanceTaxonomy()->getTaxonomyForNamespace( $namespace );
return $taxonomy
? $taxonomy->getPrefix()
: $localPrefix;
} | [
"private",
"function",
"normalizePrefix",
"(",
"$",
"localPrefix",
")",
"{",
"if",
"(",
"$",
"localPrefix",
"==",
"'xml'",
")",
"return",
"$",
"localPrefix",
";",
"$",
"namespace",
"=",
"$",
"this",
"->",
"getInstanceNamespaces",
"(",
")",
"[",
"$",
"local... | Return the schema prefix corresponding to the prefix used locally
@param string $localPrefix
@return string The updated prefix or the local one if there is no schema | [
"Return",
"the",
"schema",
"prefix",
"corresponding",
"to",
"the",
"prefix",
"used",
"locally"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Instance.php#L1384-L1393 | train |
bseddon/XBRL | XBRL-Instance.php | XBRL_Instance.getFootnoteForFact | public function getFootnoteForFact( $fact, $lang = null, $linkrole = null, $arcrole = null, $footnoterole = null )
{
if ( ! is_array( $fact ) ) return false;
if ( ! isset( $fact['id'] ) ) return false;
$href = "#{$fact['id']}";
if ( ! isset( $this->footnotes['arcs'][ $href ] ) ) return false;
if ( ! $lang ) $lang = $this->getInstanceTaxonomy()->getDefaultLanguage();
if ( ! isset( $this->footnotes[ XBRL_Constants::$footnote ][ $lang ] ) )
{
if ( ( $pos = strpos( $lang, '-' ) ) ) $lang = substr( $lang, 0, $pos );
if ( ! isset( $this->footnotes[ XBRL_Constants::$footnote ][ $lang ] ) ) return false;
}
if ( is_null( $linkrole ) ) $linkrole = XBRL_Constants::$defaultLinkRole;
if ( is_null( $arcrole ) ) $arcrole = XBRL_Constants::$arcRoleFactFootnote;
if ( is_null( $footnoterole ) ) $footnoterole = XBRL_Constants::$footnote;
// The role implied by $arcrole must be valid (contain arcs that use the arcrole)
if ( ! isset( $this->footnotes['arcroles'][ $arcrole ] ) || ! in_array( $linkrole, $this->footnotes['arcroles'][ $arcrole ] ) )
{
return array();
}
// Based on the linkrole, workout the valid footnotes to include
$footnoteIds = $this->footnotes['arcs'][ $href ][ $linkrole ]['footnote'];
// Use the footnote ids to select the label text
$footnotes = array();
foreach ( $footnoteIds as $footnodeId )
{
if ( ! isset( $this->footnotes[ $footnoterole ][ $lang ][ $footnodeId ][ $linkrole ] ) )
{
continue;
}
$footnotes[] = $this->footnotes[ $footnoterole ][ $lang ][ $footnodeId ][ $linkrole ];
}
return $footnotes;
} | php | public function getFootnoteForFact( $fact, $lang = null, $linkrole = null, $arcrole = null, $footnoterole = null )
{
if ( ! is_array( $fact ) ) return false;
if ( ! isset( $fact['id'] ) ) return false;
$href = "#{$fact['id']}";
if ( ! isset( $this->footnotes['arcs'][ $href ] ) ) return false;
if ( ! $lang ) $lang = $this->getInstanceTaxonomy()->getDefaultLanguage();
if ( ! isset( $this->footnotes[ XBRL_Constants::$footnote ][ $lang ] ) )
{
if ( ( $pos = strpos( $lang, '-' ) ) ) $lang = substr( $lang, 0, $pos );
if ( ! isset( $this->footnotes[ XBRL_Constants::$footnote ][ $lang ] ) ) return false;
}
if ( is_null( $linkrole ) ) $linkrole = XBRL_Constants::$defaultLinkRole;
if ( is_null( $arcrole ) ) $arcrole = XBRL_Constants::$arcRoleFactFootnote;
if ( is_null( $footnoterole ) ) $footnoterole = XBRL_Constants::$footnote;
// The role implied by $arcrole must be valid (contain arcs that use the arcrole)
if ( ! isset( $this->footnotes['arcroles'][ $arcrole ] ) || ! in_array( $linkrole, $this->footnotes['arcroles'][ $arcrole ] ) )
{
return array();
}
// Based on the linkrole, workout the valid footnotes to include
$footnoteIds = $this->footnotes['arcs'][ $href ][ $linkrole ]['footnote'];
// Use the footnote ids to select the label text
$footnotes = array();
foreach ( $footnoteIds as $footnodeId )
{
if ( ! isset( $this->footnotes[ $footnoterole ][ $lang ][ $footnodeId ][ $linkrole ] ) )
{
continue;
}
$footnotes[] = $this->footnotes[ $footnoterole ][ $lang ][ $footnodeId ][ $linkrole ];
}
return $footnotes;
} | [
"public",
"function",
"getFootnoteForFact",
"(",
"$",
"fact",
",",
"$",
"lang",
"=",
"null",
",",
"$",
"linkrole",
"=",
"null",
",",
"$",
"arcrole",
"=",
"null",
",",
"$",
"footnoterole",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
... | Get a footnote for a fact or returns false
@param array $fact The element array carrying the id
@param string $lang The language code of the footnote to retrieve
@param string $linkrole
@param string $arcrole
@param string $footnoterole
@return array A list of the footnotes with an arc starting with this fact | [
"Get",
"a",
"footnote",
"for",
"a",
"fact",
"or",
"returns",
"false"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Instance.php#L2863-L2902 | train |
bseddon/XBRL | XBRL-Instance.php | XBRL_Instance.inferDecimals | public static function inferDecimals( $value, $precision )
{
if ( is_string( $value ) )
{
// BMS 2017-08-22 Removed this line because functions test 80154 V-05 fails
// and none of the XBRL 2.1 conformance tests seem to touch it.
// $value = trim( $value, "0 " );
if ( $value == 'INF' ) return "INF";
$value = intval( $value );
}
// BMS 2017-12-18 Changed test to use ===
if ( $value == 0 || $precision === "INF" ) return INF;
if ( $precision == 0 ) return false;
return $precision - intval( floor( log10( abs( $value ) ) ) ) - 1;
} | php | public static function inferDecimals( $value, $precision )
{
if ( is_string( $value ) )
{
// BMS 2017-08-22 Removed this line because functions test 80154 V-05 fails
// and none of the XBRL 2.1 conformance tests seem to touch it.
// $value = trim( $value, "0 " );
if ( $value == 'INF' ) return "INF";
$value = intval( $value );
}
// BMS 2017-12-18 Changed test to use ===
if ( $value == 0 || $precision === "INF" ) return INF;
if ( $precision == 0 ) return false;
return $precision - intval( floor( log10( abs( $value ) ) ) ) - 1;
} | [
"public",
"static",
"function",
"inferDecimals",
"(",
"$",
"value",
",",
"$",
"precision",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"value",
")",
")",
"{",
"// BMS 2017-08-22 \tRemoved this line because functions test 80154 V-05 fails\r",
"//\t\t\t\t\tand none of the X... | Infer the decimals given a value and a precision value
@param number|string $value
@param number|string $precision
@return int | [
"Infer",
"the",
"decimals",
"given",
"a",
"value",
"and",
"a",
"precision",
"value"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Instance.php#L2976-L2993 | train |
bseddon/XBRL | XBRL-Instance.php | XBRL_Instance.inferPrecision | public static function inferPrecision( $value, $decimals )
{
if ( $decimals == "INF" ) return INF;
if ( ! is_numeric( $value ) ) return false;
$fValue = floatval( $value );
if ( $value === false ) return false;
if ( $decimals === "" ) return 0;
$precision = 0;
if ( preg_match( '/[-+]?[0]*([1-9]?[0-9]*)([.])?(0*)([1-9]?[0-9]*)?([eE])?([-+]?[0-9]*)?/', $value, $matches ) )
{
list( $all, $nonZeroInt, $period, $zeroDec, $nonZeroDec, $e, $exp ) = $matches;
$precision = (
$nonZeroInt
? strlen( $nonZeroInt )
: ( $nonZeroDec ? -strlen( $zeroDec ) : 0 )
) + ( $exp ? intval( $exp ) : 0 ) + ( intval( $decimals ) );
if ( $precision < 0 ) $precision = 0;
}
return $precision;
} | php | public static function inferPrecision( $value, $decimals )
{
if ( $decimals == "INF" ) return INF;
if ( ! is_numeric( $value ) ) return false;
$fValue = floatval( $value );
if ( $value === false ) return false;
if ( $decimals === "" ) return 0;
$precision = 0;
if ( preg_match( '/[-+]?[0]*([1-9]?[0-9]*)([.])?(0*)([1-9]?[0-9]*)?([eE])?([-+]?[0-9]*)?/', $value, $matches ) )
{
list( $all, $nonZeroInt, $period, $zeroDec, $nonZeroDec, $e, $exp ) = $matches;
$precision = (
$nonZeroInt
? strlen( $nonZeroInt )
: ( $nonZeroDec ? -strlen( $zeroDec ) : 0 )
) + ( $exp ? intval( $exp ) : 0 ) + ( intval( $decimals ) );
if ( $precision < 0 ) $precision = 0;
}
return $precision;
} | [
"public",
"static",
"function",
"inferPrecision",
"(",
"$",
"value",
",",
"$",
"decimals",
")",
"{",
"if",
"(",
"$",
"decimals",
"==",
"\"INF\"",
")",
"return",
"INF",
";",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"value",
")",
")",
"return",
"false",
... | Infer the precision given a value and a decimals value
@param string|number $value
@param string|number $decimals
@return string|boolean|number | [
"Infer",
"the",
"precision",
"given",
"a",
"value",
"and",
"a",
"decimals",
"value"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Instance.php#L3023-L3047 | train |
bseddon/XBRL | XBRL-Instance.php | XBRL_Instance.getNumericPresentation | function getNumericPresentation( &$entry )
{
if ( isset( $entry['precision'] ) && strval( $entry['precision'] ) === '0' )
{
return NAN;
}
// Using PHP_ROUND_HALF_EVEN see XBRL 2.1 section 4.6.7.2
$decimals = $this->getDecimals( $entry );
return $decimals == INF
? $entry['value']
: round( $entry['value'], $this->getDecimals( $entry ), PHP_ROUND_HALF_EVEN );
} | php | function getNumericPresentation( &$entry )
{
if ( isset( $entry['precision'] ) && strval( $entry['precision'] ) === '0' )
{
return NAN;
}
// Using PHP_ROUND_HALF_EVEN see XBRL 2.1 section 4.6.7.2
$decimals = $this->getDecimals( $entry );
return $decimals == INF
? $entry['value']
: round( $entry['value'], $this->getDecimals( $entry ), PHP_ROUND_HALF_EVEN );
} | [
"function",
"getNumericPresentation",
"(",
"&",
"$",
"entry",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"entry",
"[",
"'precision'",
"]",
")",
"&&",
"strval",
"(",
"$",
"entry",
"[",
"'precision'",
"]",
")",
"===",
"'0'",
")",
"{",
"return",
"NAN",
";"... | Generate a presentation of a fact value taking into account decimals and precision settings
@param array $entry (by reference) The fact entry containing the value
@return string | [
"Generate",
"a",
"presentation",
"of",
"a",
"fact",
"value",
"taking",
"into",
"account",
"decimals",
"and",
"precision",
"settings"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Instance.php#L3073-L3085 | train |
bseddon/XBRL | XBRL-Instance.php | XBRL_Instance.validateFacts | private function validateFacts( $elements, $parent, &$types, &$prefixes )
{
$instanceTaxonomy = $this->getInstanceTaxonomy();
$primaryItems = $instanceTaxonomy->getDefinitionPrimaryItems( false );
foreach ( $elements as $factKey => $fact )
{
$drsHypercubes = false;
foreach ( $fact as $entryKey => $entry )
{
// This function will return an empty array if there is no primary item or if the primary item is not
// associated with any hypercubes. Otherwise it will contain summary information about the dimensional
// validation of the primary item. If the dimensional validation fails it means the fact is not
// associated with any hypercubes valid for the fact context.
$primaryItem = isset( $primaryItems[ $entry['label'] ] ) ? $primaryItems[ $entry['label'] ] : false;
if ( $primaryItem && ! $drsHypercubes )
{
$drsHypercubes = $this->getInstanceTaxonomy()->getPrimaryItemDRS( $primaryItem );
}
$dimensionalValidation = $this->validateElementEntry( $entry, $factKey, $parent, $types, $prefixes, $primaryItem, $drsHypercubes );
}
}
} | php | private function validateFacts( $elements, $parent, &$types, &$prefixes )
{
$instanceTaxonomy = $this->getInstanceTaxonomy();
$primaryItems = $instanceTaxonomy->getDefinitionPrimaryItems( false );
foreach ( $elements as $factKey => $fact )
{
$drsHypercubes = false;
foreach ( $fact as $entryKey => $entry )
{
// This function will return an empty array if there is no primary item or if the primary item is not
// associated with any hypercubes. Otherwise it will contain summary information about the dimensional
// validation of the primary item. If the dimensional validation fails it means the fact is not
// associated with any hypercubes valid for the fact context.
$primaryItem = isset( $primaryItems[ $entry['label'] ] ) ? $primaryItems[ $entry['label'] ] : false;
if ( $primaryItem && ! $drsHypercubes )
{
$drsHypercubes = $this->getInstanceTaxonomy()->getPrimaryItemDRS( $primaryItem );
}
$dimensionalValidation = $this->validateElementEntry( $entry, $factKey, $parent, $types, $prefixes, $primaryItem, $drsHypercubes );
}
}
} | [
"private",
"function",
"validateFacts",
"(",
"$",
"elements",
",",
"$",
"parent",
",",
"&",
"$",
"types",
",",
"&",
"$",
"prefixes",
")",
"{",
"$",
"instanceTaxonomy",
"=",
"$",
"this",
"->",
"getInstanceTaxonomy",
"(",
")",
";",
"$",
"primaryItems",
"="... | Process each fact in the instance document which may have multiple entries
@param array $elements
@param string $parent An identifier representing the parent node in the instance document
@param XBRL_Types $types
@param array $prefixes | [
"Process",
"each",
"fact",
"in",
"the",
"instance",
"document",
"which",
"may",
"have",
"multiple",
"entries"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Instance.php#L3558-L3582 | train |
bseddon/XBRL | XBRL-Instance.php | XBRL_Instance.validateRequiresElementArcs | private function validateRequiresElementArcs( XBRL_Types &$types )
{
$arcs = $this->getInstanceTaxonomy()->getRequireElementsList();
if ( ! $arcs ) return true;
foreach ( $arcs as $from => $targets )
{
// echo "$from";
// If the $from exists then the $to exists
$parts = parse_url( $from );
if ( ! isset( $parts['path'] ) || ! isset( $parts['fragment'] ) ) continue;
$fromTaxonomy = $this->getInstanceTaxonomy()->getTaxonomyForXSD( $parts['path'] );
if ( ! $fromTaxonomy )
{
$this->log()->instance_validation( "5.2.6.2.4", "The taxonomy of the source does not exist in the DTS",
array(
'from' => $from,
)
);
continue;
}
$fromElement = $fromTaxonomy->getElementById( $parts['fragment'] );
if ( ! $fromElement )
{
$this->log()->instance_validation( "5.2.6.2.4", "The concept of the source does not exist in the DTS",
array(
'from' => $from,
)
);
continue;
}
// Look for the fact in the instance document
$fromFact = $this->getElement( $fromElement['id'] );
// If the $from does not exist there is noting else to do
if ( ! $fromFact ) continue;
foreach ( $targets as $target => $details )
{
// echo " -> $target\n";
$parts = parse_url( $target );
if ( ! isset( $parts['path'] ) || ! isset( $parts['fragment'] ) ) continue;
$toTaxonomy = $this->getInstanceTaxonomy()->getTaxonomyForXSD( $parts['path'] );
if ( ! $toTaxonomy )
{
$this->log()->instance_validation( "5.2.6.2.4", "The taxonomy of the target does not exist in the DTS",
array(
'from' => $from,
)
);
continue;
}
$toElement = $toTaxonomy->getElementById( $parts['fragment'] );
if ( ! $toElement )
{
$this->log()->instance_validation( "5.2.6.2.4", "The concept of the target does not exist in the DTS",
array(
'to' => $to,
)
);
continue;
}
// Look for the fact in the instance document
$toFact = $this->getElement( $toElement['id'] );
// If the $from does not exist there is noting else to do
if ( $toFact ) continue;
// The $from exist but the $to does not so report the error.
$this->log()->instance_validation( "5.2.6.2.4", "The required source fact exists but the target one does not exist.",
array(
'from' => $from,
'to' => $target,
)
);
}
}
} | php | private function validateRequiresElementArcs( XBRL_Types &$types )
{
$arcs = $this->getInstanceTaxonomy()->getRequireElementsList();
if ( ! $arcs ) return true;
foreach ( $arcs as $from => $targets )
{
// echo "$from";
// If the $from exists then the $to exists
$parts = parse_url( $from );
if ( ! isset( $parts['path'] ) || ! isset( $parts['fragment'] ) ) continue;
$fromTaxonomy = $this->getInstanceTaxonomy()->getTaxonomyForXSD( $parts['path'] );
if ( ! $fromTaxonomy )
{
$this->log()->instance_validation( "5.2.6.2.4", "The taxonomy of the source does not exist in the DTS",
array(
'from' => $from,
)
);
continue;
}
$fromElement = $fromTaxonomy->getElementById( $parts['fragment'] );
if ( ! $fromElement )
{
$this->log()->instance_validation( "5.2.6.2.4", "The concept of the source does not exist in the DTS",
array(
'from' => $from,
)
);
continue;
}
// Look for the fact in the instance document
$fromFact = $this->getElement( $fromElement['id'] );
// If the $from does not exist there is noting else to do
if ( ! $fromFact ) continue;
foreach ( $targets as $target => $details )
{
// echo " -> $target\n";
$parts = parse_url( $target );
if ( ! isset( $parts['path'] ) || ! isset( $parts['fragment'] ) ) continue;
$toTaxonomy = $this->getInstanceTaxonomy()->getTaxonomyForXSD( $parts['path'] );
if ( ! $toTaxonomy )
{
$this->log()->instance_validation( "5.2.6.2.4", "The taxonomy of the target does not exist in the DTS",
array(
'from' => $from,
)
);
continue;
}
$toElement = $toTaxonomy->getElementById( $parts['fragment'] );
if ( ! $toElement )
{
$this->log()->instance_validation( "5.2.6.2.4", "The concept of the target does not exist in the DTS",
array(
'to' => $to,
)
);
continue;
}
// Look for the fact in the instance document
$toFact = $this->getElement( $toElement['id'] );
// If the $from does not exist there is noting else to do
if ( $toFact ) continue;
// The $from exist but the $to does not so report the error.
$this->log()->instance_validation( "5.2.6.2.4", "The required source fact exists but the target one does not exist.",
array(
'from' => $from,
'to' => $target,
)
);
}
}
} | [
"private",
"function",
"validateRequiresElementArcs",
"(",
"XBRL_Types",
"&",
"$",
"types",
")",
"{",
"$",
"arcs",
"=",
"$",
"this",
"->",
"getInstanceTaxonomy",
"(",
")",
"->",
"getRequireElementsList",
"(",
")",
";",
"if",
"(",
"!",
"$",
"arcs",
")",
"re... | Validate any requires element arcs
@param XBRL_Types $types
@return boolean | [
"Validate",
"any",
"requires",
"element",
"arcs"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Instance.php#L3590-L3677 | train |
bseddon/XBRL | XBRL-Instance.php | XBRL_Instance.validateDivide | private function validateDivide( $divide, $unitId, $types )
{
$numeratorValidation = true;
$denominatorValidation = true;
// The divide MUST and a numerator and a denominator
if ( isset( $divide['numerator'] ) )
{
if ( empty( $divide['numerator'] ) )
{
$this->log()->instance_validation( "4.8.4", "The 'unitNumerator' MUST NOT be empty", array( 'unit' => $unitId ) );
$numeratorValidation = false;
}
else
{
foreach ( $divide['numerator'] as $measure )
{
$numeratorValidation &= $this->validateMeasure( $measure, "$unitId (numerator)", $types );
}
}
}
else
{
$this->log()->instance_validation( "4.8.3", "Both a 'unitNumerator' and a 'unitDenominator' MUST be provided. The numerator is missing.", array( 'unit' => $unitId ) );
$numeratorValidation = false;
}
// The divide MUST and a numerator and a denominator
if ( isset( $divide['denominator'] ) )
{
if ( empty( $divide['denominator'] ) )
{
$this->log()->instance_validation( "4.8.4", "The 'unitDenominator' MUST NOT be empty", array( 'unit' => $unitId ) );
$denominatorValidation = false;
}
else
{
foreach ( $divide['denominator'] as $measure )
{
$denominatorValidation &= $this->validateMeasure( $measure, "$unitId (denominator)", $types );
}
}
}
else
{
$this->log()->instance_validation( "4.8.3", "Both a 'unitNumerator' and a 'unitDenominator' MUST be provided. The denominator is missing.", array( 'unit' => $unitId ) );
$denominatorValidation = false;
}
if ( ! $numeratorValidation || ! $denominatorValidation ) return false;
// Check the denominator measures do not appear in the numerator measures
// First create a list of all the numerator qnames
$qNames = array();
foreach ( $divide['numerator'] as $measure )
{
$qNames[] = qname( $measure, $this->instance_namespaces )->clarkNotation();
}
foreach ( $divide['denominator'] as $measure )
{
$qName = qname( $measure, $this->instance_namespaces + array( STANDARD_PREFIX_XBRLI => XBRL_Constants::$standardPrefixes[ STANDARD_PREFIX_XBRLI ] ) );
if ( in_array( $qName->clarkNotation(), $qNames ) )
{
XBRL_Log::getInstance()->instance_validation( "4.8.4", "The measure in a denominator cannot appear in a numerator", array( 'unit' => $unitId, 'measure' => $measure ) );
return false;
}
}
return true;
} | php | private function validateDivide( $divide, $unitId, $types )
{
$numeratorValidation = true;
$denominatorValidation = true;
// The divide MUST and a numerator and a denominator
if ( isset( $divide['numerator'] ) )
{
if ( empty( $divide['numerator'] ) )
{
$this->log()->instance_validation( "4.8.4", "The 'unitNumerator' MUST NOT be empty", array( 'unit' => $unitId ) );
$numeratorValidation = false;
}
else
{
foreach ( $divide['numerator'] as $measure )
{
$numeratorValidation &= $this->validateMeasure( $measure, "$unitId (numerator)", $types );
}
}
}
else
{
$this->log()->instance_validation( "4.8.3", "Both a 'unitNumerator' and a 'unitDenominator' MUST be provided. The numerator is missing.", array( 'unit' => $unitId ) );
$numeratorValidation = false;
}
// The divide MUST and a numerator and a denominator
if ( isset( $divide['denominator'] ) )
{
if ( empty( $divide['denominator'] ) )
{
$this->log()->instance_validation( "4.8.4", "The 'unitDenominator' MUST NOT be empty", array( 'unit' => $unitId ) );
$denominatorValidation = false;
}
else
{
foreach ( $divide['denominator'] as $measure )
{
$denominatorValidation &= $this->validateMeasure( $measure, "$unitId (denominator)", $types );
}
}
}
else
{
$this->log()->instance_validation( "4.8.3", "Both a 'unitNumerator' and a 'unitDenominator' MUST be provided. The denominator is missing.", array( 'unit' => $unitId ) );
$denominatorValidation = false;
}
if ( ! $numeratorValidation || ! $denominatorValidation ) return false;
// Check the denominator measures do not appear in the numerator measures
// First create a list of all the numerator qnames
$qNames = array();
foreach ( $divide['numerator'] as $measure )
{
$qNames[] = qname( $measure, $this->instance_namespaces )->clarkNotation();
}
foreach ( $divide['denominator'] as $measure )
{
$qName = qname( $measure, $this->instance_namespaces + array( STANDARD_PREFIX_XBRLI => XBRL_Constants::$standardPrefixes[ STANDARD_PREFIX_XBRLI ] ) );
if ( in_array( $qName->clarkNotation(), $qNames ) )
{
XBRL_Log::getInstance()->instance_validation( "4.8.4", "The measure in a denominator cannot appear in a numerator", array( 'unit' => $unitId, 'measure' => $measure ) );
return false;
}
}
return true;
} | [
"private",
"function",
"validateDivide",
"(",
"$",
"divide",
",",
"$",
"unitId",
",",
"$",
"types",
")",
"{",
"$",
"numeratorValidation",
"=",
"true",
";",
"$",
"denominatorValidation",
"=",
"true",
";",
"// The divide MUST and a numerator and a denominator\r",
"if"... | Validates the measure component of a unit definition
@param string $divide
@param string $unitId
@param XBRL_Types $types | [
"Validates",
"the",
"measure",
"component",
"of",
"a",
"unit",
"definition"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Instance.php#L5512-L5582 | train |
bseddon/XBRL | XBRL-Instance.php | XBRL_Instance.validateMeasure | private function validateMeasure( $measure, $unitId, $types, $forceCurrencyCheck = false )
{
if ( empty( $measure ) )
{
$this->log()->instance_validation( "4.8.2", "The measure cannot be empty", array( 'unit' => $unitId ) );
return false;
}
// The measure must have a value that is a qname with a prefix in scope or a value with a namespace provided as an attribute.
$qName = qname( $measure, $this->instance_namespaces + array( STANDARD_PREFIX_XBRLI => XBRL_Constants::$standardPrefixes[ STANDARD_PREFIX_XBRLI ] ) );
if ( ! $qName )
{
$this->log()->instance_validation( "4.8.2", "The measure value is not valid",
array(
'unit' => $unitId,
'measure' => $measure,
)
);
return false;
}
if ( $qName->namespaceURI == XBRL_Constants::$standardPrefixes[ STANDARD_PREFIX_ISO4217 ] )
{
// The local name value MUST be a valid ISO country code. A minimum is that it should be three characters.
if ( strlen( $qName->localName ) == 3 ) return true;
$this->log()->instance_validation( "4.8.2", "The measure value is not a valid ISO country code",
array(
'unit' => $unitId,
'measure' => $measure,
)
);
return false;
}
if ( $forceCurrencyCheck )
{
$this->log()->instance_validation( "4.8.2", "The measure value for monetary facts must be a valid ISO country code",
array(
'unit' => $unitId,
'measure' => $measure,
)
);
return false;
}
// BMS 2018-04-18 This test is not quite right because it's the local name that MUST be pure or shares if the namespace resolves to xbrli
// From 4.8.2: A <measure> element with a namespace prefix that resolves to the
// "http://www.xbrl.org/2003/instance" namespace MUST have a local
// part of either "pure" or "shares".
// if ( $qName->localName == 'pure' && ! isset( $this->instance_namespaces[ $qName->prefix ] ) )
// if ( $qName->localName == 'pure' && $qName->prefix == STANDARD_PREFIX_XBRLI )
// {
// if ( $qName->namespaceURI == XBRL_Constants::$standardPrefixes[ STANDARD_PREFIX_XBRLI ] ) return true;
// $this->log()->instance_validation( "4.8.2", "The xbrli:pure measure must have a namespace of http://www.xbrl.org/2003/instance",
// array(
// 'unit' => $unitId,
// 'measure' => $measure,
// )
// );
// return false;
// }
//
// if ( $qName->localName == 'shares' )
// {
// if ( $qName->namespaceURI == XBRL_Constants::$standardPrefixes[ STANDARD_PREFIX_XBRLI ] ) return true;
// $this->log()->instance_validation( "4.8.2", "The shares measure must have a namespace of http://www.xbrl.org/2003/instance",
// array(
// 'unit' => $unitId,
// 'measure' => $measure,
// )
// );
// return false;
// }
if ( $qName->namespaceURI == XBRL_Constants::$standardPrefixes[ STANDARD_PREFIX_XBRLI ] )
{
if ( ! in_array( $qName->localName, array( 'pure', 'shares' ) ) )
{
$this->log()->instance_validation( "4.8.2", "A measure with a namespace of http://www.xbrl.org/2003/instance MUST be 'pure' or 'shares'",
array(
'unit' => $unitId,
'measure' => $measure,
)
);
return false;
}
}
// Otherwise the namespace must be in scope
return true;
} | php | private function validateMeasure( $measure, $unitId, $types, $forceCurrencyCheck = false )
{
if ( empty( $measure ) )
{
$this->log()->instance_validation( "4.8.2", "The measure cannot be empty", array( 'unit' => $unitId ) );
return false;
}
// The measure must have a value that is a qname with a prefix in scope or a value with a namespace provided as an attribute.
$qName = qname( $measure, $this->instance_namespaces + array( STANDARD_PREFIX_XBRLI => XBRL_Constants::$standardPrefixes[ STANDARD_PREFIX_XBRLI ] ) );
if ( ! $qName )
{
$this->log()->instance_validation( "4.8.2", "The measure value is not valid",
array(
'unit' => $unitId,
'measure' => $measure,
)
);
return false;
}
if ( $qName->namespaceURI == XBRL_Constants::$standardPrefixes[ STANDARD_PREFIX_ISO4217 ] )
{
// The local name value MUST be a valid ISO country code. A minimum is that it should be three characters.
if ( strlen( $qName->localName ) == 3 ) return true;
$this->log()->instance_validation( "4.8.2", "The measure value is not a valid ISO country code",
array(
'unit' => $unitId,
'measure' => $measure,
)
);
return false;
}
if ( $forceCurrencyCheck )
{
$this->log()->instance_validation( "4.8.2", "The measure value for monetary facts must be a valid ISO country code",
array(
'unit' => $unitId,
'measure' => $measure,
)
);
return false;
}
// BMS 2018-04-18 This test is not quite right because it's the local name that MUST be pure or shares if the namespace resolves to xbrli
// From 4.8.2: A <measure> element with a namespace prefix that resolves to the
// "http://www.xbrl.org/2003/instance" namespace MUST have a local
// part of either "pure" or "shares".
// if ( $qName->localName == 'pure' && ! isset( $this->instance_namespaces[ $qName->prefix ] ) )
// if ( $qName->localName == 'pure' && $qName->prefix == STANDARD_PREFIX_XBRLI )
// {
// if ( $qName->namespaceURI == XBRL_Constants::$standardPrefixes[ STANDARD_PREFIX_XBRLI ] ) return true;
// $this->log()->instance_validation( "4.8.2", "The xbrli:pure measure must have a namespace of http://www.xbrl.org/2003/instance",
// array(
// 'unit' => $unitId,
// 'measure' => $measure,
// )
// );
// return false;
// }
//
// if ( $qName->localName == 'shares' )
// {
// if ( $qName->namespaceURI == XBRL_Constants::$standardPrefixes[ STANDARD_PREFIX_XBRLI ] ) return true;
// $this->log()->instance_validation( "4.8.2", "The shares measure must have a namespace of http://www.xbrl.org/2003/instance",
// array(
// 'unit' => $unitId,
// 'measure' => $measure,
// )
// );
// return false;
// }
if ( $qName->namespaceURI == XBRL_Constants::$standardPrefixes[ STANDARD_PREFIX_XBRLI ] )
{
if ( ! in_array( $qName->localName, array( 'pure', 'shares' ) ) )
{
$this->log()->instance_validation( "4.8.2", "A measure with a namespace of http://www.xbrl.org/2003/instance MUST be 'pure' or 'shares'",
array(
'unit' => $unitId,
'measure' => $measure,
)
);
return false;
}
}
// Otherwise the namespace must be in scope
return true;
} | [
"private",
"function",
"validateMeasure",
"(",
"$",
"measure",
",",
"$",
"unitId",
",",
"$",
"types",
",",
"$",
"forceCurrencyCheck",
"=",
"false",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"measure",
")",
")",
"{",
"$",
"this",
"->",
"log",
"(",
")",
... | Validates the divide component of a unit definition
@param string $measure
@param string $unitId
@param XBRL_Types $types
@param bool $forceCurrencyCheck
@return bool Return false if there has been any validation issue | [
"Validates",
"the",
"divide",
"component",
"of",
"a",
"unit",
"definition"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Instance.php#L5594-L5685 | train |
bseddon/XBRL | XBRL-Instance.php | XBRL_Instance.validateExplicitMembers | private function validateExplicitMembers( $component, $contextId, $types, $componentName, &$data )
{
// The component should not be empty
if ( XBRL_Instance::isEmpty( $component, 'dimension' ) || XBRL_Instance::isEmpty( $component, 'member' ) )
{
XBRL_Log::getInstance()->instance_validation(
$componentName == XBRL_Constants::$xbrliScenario
? "4.7.4"
: "4.7.3.2", "A $componentName cannot be empty",
array(
'context' => $contextId
)
);
}
// To finish when doing dimensional validation
if ( is_null( $data ) ) $data = array();
// Anyone dimension should appear only once in a component
if ( isset( $data[ $component['dimension'] ] ) )
{
$this->log()->dimension_validation(
"3.1.4.2",
"Dimensions have been repeated in scenario or segment components of a context",
array(
'context' => "'$contextId'",
'dimension' => "'{$component['dimension']}'",
'error' => 'xbrldie:RepeatedDimensionInInstanceError',
)
);
return false;
}
// Record this for any future iteration
$data[ $component['dimension'] ] = true;
// $dimTaxonomy = $this->getInstanceTaxonomy()->getTaxonomyForNamespace( $item['dimension']['namespace'] );
// $dimXsd = $dimTaxonomy->getTaxonomyXSD();
// $dim = "$dimXsd#{$item['dimension']['element']['id']}";
// $dimElement = $dimTaxonomy->getElementById( $dim );
$parts = explode( ':', $component['dimension'] );
$dimension = $this->getElementForReference( $parts[0], $parts[1], false );
// The dimension MUST be explicit 3.1.4.5.2 xbrldie:ExplicitMemberNotExplicitDimensionError
if ( ! $dimension ||
! $types->resolveToSubstitutionGroup( $dimension['element']['substitutionGroup'], array( XBRL_Constants::$xbrldtDimensionItem ) ) ||
isset( $dimension['element']['typedDomainRef'] )
)
{
$this->log()->dimension_validation(
"3.1.4.5.2",
"The dimension MUST resolve to an explicit dimension taxonomy element",
array(
'context' => "'$contextId'",
'dimension' => "'{$component['dimension']}'",
'error' => 'xbrldie:ExplicitMemberNotExplicitDimensionError',
)
);
}
$memElement = false;
$parts = explode( ':', $component['member'] );
$member = $this->getElementForReference( $parts[0], $parts[1], false );
// The content of the xbrldi:explicitMember element MUST be a QName whose global element
// definition can be found in the taxonomy schema referenced by the namespace of the QName.
// A dimensional processor MUST raise an error xbrldie:ExplicitMemberUndefinedQNameError
// if this rule is violated.
if ( ! $member )
{
$this->log()->dimension_validation(
"3.1.4.5.3",
"The dimension member MUST resolve to a taxonomy element",
array(
'context' => "'$contextId'",
'dimension' => "'{$component['dimension']}'",
'member' => "'{$component['member']}'",
'error' => 'xbrldie:ExplicitMemberUndefinedQNameError',
)
);
}
return true;
} | php | private function validateExplicitMembers( $component, $contextId, $types, $componentName, &$data )
{
// The component should not be empty
if ( XBRL_Instance::isEmpty( $component, 'dimension' ) || XBRL_Instance::isEmpty( $component, 'member' ) )
{
XBRL_Log::getInstance()->instance_validation(
$componentName == XBRL_Constants::$xbrliScenario
? "4.7.4"
: "4.7.3.2", "A $componentName cannot be empty",
array(
'context' => $contextId
)
);
}
// To finish when doing dimensional validation
if ( is_null( $data ) ) $data = array();
// Anyone dimension should appear only once in a component
if ( isset( $data[ $component['dimension'] ] ) )
{
$this->log()->dimension_validation(
"3.1.4.2",
"Dimensions have been repeated in scenario or segment components of a context",
array(
'context' => "'$contextId'",
'dimension' => "'{$component['dimension']}'",
'error' => 'xbrldie:RepeatedDimensionInInstanceError',
)
);
return false;
}
// Record this for any future iteration
$data[ $component['dimension'] ] = true;
// $dimTaxonomy = $this->getInstanceTaxonomy()->getTaxonomyForNamespace( $item['dimension']['namespace'] );
// $dimXsd = $dimTaxonomy->getTaxonomyXSD();
// $dim = "$dimXsd#{$item['dimension']['element']['id']}";
// $dimElement = $dimTaxonomy->getElementById( $dim );
$parts = explode( ':', $component['dimension'] );
$dimension = $this->getElementForReference( $parts[0], $parts[1], false );
// The dimension MUST be explicit 3.1.4.5.2 xbrldie:ExplicitMemberNotExplicitDimensionError
if ( ! $dimension ||
! $types->resolveToSubstitutionGroup( $dimension['element']['substitutionGroup'], array( XBRL_Constants::$xbrldtDimensionItem ) ) ||
isset( $dimension['element']['typedDomainRef'] )
)
{
$this->log()->dimension_validation(
"3.1.4.5.2",
"The dimension MUST resolve to an explicit dimension taxonomy element",
array(
'context' => "'$contextId'",
'dimension' => "'{$component['dimension']}'",
'error' => 'xbrldie:ExplicitMemberNotExplicitDimensionError',
)
);
}
$memElement = false;
$parts = explode( ':', $component['member'] );
$member = $this->getElementForReference( $parts[0], $parts[1], false );
// The content of the xbrldi:explicitMember element MUST be a QName whose global element
// definition can be found in the taxonomy schema referenced by the namespace of the QName.
// A dimensional processor MUST raise an error xbrldie:ExplicitMemberUndefinedQNameError
// if this rule is violated.
if ( ! $member )
{
$this->log()->dimension_validation(
"3.1.4.5.3",
"The dimension member MUST resolve to a taxonomy element",
array(
'context' => "'$contextId'",
'dimension' => "'{$component['dimension']}'",
'member' => "'{$component['member']}'",
'error' => 'xbrldie:ExplicitMemberUndefinedQNameError',
)
);
}
return true;
} | [
"private",
"function",
"validateExplicitMembers",
"(",
"$",
"component",
",",
"$",
"contextId",
",",
"$",
"types",
",",
"$",
"componentName",
",",
"&",
"$",
"data",
")",
"{",
"// The component should not be empty\r",
"if",
"(",
"XBRL_Instance",
"::",
"isEmpty",
... | Used to validate explicit members in dimensional texonomies
@param array $component The explicit segment or scenario member information
@param string $contextId The id of the context
@param XBRL_Types $types
@param string $componentName The name of the component: scenario or segment
@param array|null $data An object of data created to pass information between function calls
@return boolean | [
"Used",
"to",
"validate",
"explicit",
"members",
"in",
"dimensional",
"texonomies"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Instance.php#L5697-L5783 | train |
bseddon/XBRL | XBRL-Instance.php | XBRL_Instance.validateOtherComponentTypes | private function validateOtherComponentTypes( $componenttMembers, $contextId, $types, $componentName, &$data )
{
// Can't have element types that are defined in the XBRLI namespace
// Workout what prefix is used for the XBRLI namespace
$xbrliPrefixes = array( 'xbrli' );
foreach ( $this->instance_namespaces as $prefix => $namespace )
{
if ( $namespace == XBRL_Constants::$standardPrefixes[ STANDARD_PREFIX_XBRLI ] )
{
array_push( $xbrliPrefixes, $prefix );
}
}
$findPrefixes = function( $nodes ) use( &$findPrefixes, $xbrliPrefixes )
{
if ( isset( $nodes['prefix'] ) && in_array( $nodes['prefix'], $xbrliPrefixes ) ) return true;
if ( isset( $nodes['children'] ) )
{
if ( $findPrefixes( $nodes['children'] ) ) return true;
}
else
{
foreach ( $nodes as $key => $node )
{
if ( ! is_array( $node ) ) continue;
if ( $findPrefixes( $node ) ) return true;
}
}
return false;
};
if ( $findPrefixes( $componenttMembers ) )
{
XBRL_Log::getInstance()->instance_validation( "4.7.3.2", "The context $componentName content contains one or more elements in the XBRLI namespace",
array(
'content' => $contextId,
)
);
}
return true;
} | php | private function validateOtherComponentTypes( $componenttMembers, $contextId, $types, $componentName, &$data )
{
// Can't have element types that are defined in the XBRLI namespace
// Workout what prefix is used for the XBRLI namespace
$xbrliPrefixes = array( 'xbrli' );
foreach ( $this->instance_namespaces as $prefix => $namespace )
{
if ( $namespace == XBRL_Constants::$standardPrefixes[ STANDARD_PREFIX_XBRLI ] )
{
array_push( $xbrliPrefixes, $prefix );
}
}
$findPrefixes = function( $nodes ) use( &$findPrefixes, $xbrliPrefixes )
{
if ( isset( $nodes['prefix'] ) && in_array( $nodes['prefix'], $xbrliPrefixes ) ) return true;
if ( isset( $nodes['children'] ) )
{
if ( $findPrefixes( $nodes['children'] ) ) return true;
}
else
{
foreach ( $nodes as $key => $node )
{
if ( ! is_array( $node ) ) continue;
if ( $findPrefixes( $node ) ) return true;
}
}
return false;
};
if ( $findPrefixes( $componenttMembers ) )
{
XBRL_Log::getInstance()->instance_validation( "4.7.3.2", "The context $componentName content contains one or more elements in the XBRLI namespace",
array(
'content' => $contextId,
)
);
}
return true;
} | [
"private",
"function",
"validateOtherComponentTypes",
"(",
"$",
"componenttMembers",
",",
"$",
"contextId",
",",
"$",
"types",
",",
"$",
"componentName",
",",
"&",
"$",
"data",
")",
"{",
"// Can't have element types that are defined in the XBRLI namespace\r",
"// Workout ... | Validate segment and scenarios that have custom elements as their content
@param array $componenttMembers A list of nodes
@param string $contextId The id of the current context
@param XBRL_Types $types A reference to the global types instance
@param string $componentName The name of the component: scenario or segment
@param array|null $data An object of data created to pass information between function calls
@return boolean | [
"Validate",
"segment",
"and",
"scenarios",
"that",
"have",
"custom",
"elements",
"as",
"their",
"content"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Instance.php#L6020-L6062 | train |
bseddon/XBRL | XBRL-Instance.php | XBRL_Instance.validateNonDimensionMembers | private function validateNonDimensionMembers( $component, $contextId, $types, $componentName, &$data )
{
if ( empty( $component ) )
{
XBRL_Log::getInstance()->instance_validation(
$componentName == XBRL_Constants::$xbrliScenario
? "4.7.4"
: "4.7.3.2", "A $componentName cannot be empty",
array(
'context' => $contextId,
)
);
return false;
}
$qName = qname( $component['name'], $this->instance_namespaces );
// BMS 2018-04-30 This is rubbish. It's the elements inside the component that must not be in xbrli
// The $component element cannot be in the xbrli namespace
// if ( $qName->namespaceURI == XBRL_Constants::$standardPrefixes[ STANDARD_PREFIX_XBRLI ] )
// {
// XBRL_Log::getInstance()->instance_validation(
// $componentName == 'scenario'
// ? "4.7.4"
// : "4.7.3.2",
// "A $componentName element cannot be in the xbrl instance namespace",
// array(
// 'context' => $contextId,
// )
// );
// return false;
// }
// Check the member is valid
// Don't look for the element type in the types collection.
// Look for it in the taxonomy element
$taxonomy = $this->getInstanceTaxonomy()->getTaxonomyForNamespace( $qName->namespaceURI );
if ( $taxonomy )
{
$element = $taxonomy->getElementByName( $qName->localName );
if ( ! XBRL_Instance::isEmpty( $element, 'substitutionGroup' ) )
{
if ( $types->resolveToSubstitutionGroup( $element['substitutionGroup'], array( XBRL_Constants::$xbrliItem ) ) )
{
XBRL_Log::getInstance()->instance_validation(
$componentName == 'scenario'
? "4.7.4"
: "4.7.3.2", "A $componentName cannot include an element that is in the xbrli:item substitution group",
array(
'context' => $contextId,
)
);
return false;
}
}
if ( $element && ( ! XBRL_Instance::isEmpty( $element, 'type' ) || isset( $element['types'] ) ) )
{
$type = XBRL_Instance::isEmpty( $element, 'type' )
? ( count( $element['types'] ) ? $element['types'][0] : "" )
: $element['type'];
// If the schema type is a string lookup the type
if ( is_string( $type ) )
{
$qName = qname( $type, $this->instance_namespaces + array( 'xbrli' => XBRL_Constants::$standardPrefixes[ STANDARD_PREFIX_XBRLI ] ) );
$type = $types->getType( $qName->localName, $qName->prefix );
}
if ( is_array( $type ) )
{
if ( isset( $type['values'] ) )
{
// if ( in_array( $component['member'], $type['values'] ) )
if ( in_array( $component['member'], array_map( function( $value ) { return $value['value']; }, $type['values'] ) ) )
{
return true;
}
XBRL_Log::getInstance()->instance_validation(
$componentName == 'scenario'
? "4.7.4"
: "4.7.3.2",
"The $componentName type/member is not valid",
array(
'context' => $contextId,
)
);
return false;
}
else if ( isset( $type['sequence'] ) )
{
echo "seq\n";
}
}
}
}
return true;
} | php | private function validateNonDimensionMembers( $component, $contextId, $types, $componentName, &$data )
{
if ( empty( $component ) )
{
XBRL_Log::getInstance()->instance_validation(
$componentName == XBRL_Constants::$xbrliScenario
? "4.7.4"
: "4.7.3.2", "A $componentName cannot be empty",
array(
'context' => $contextId,
)
);
return false;
}
$qName = qname( $component['name'], $this->instance_namespaces );
// BMS 2018-04-30 This is rubbish. It's the elements inside the component that must not be in xbrli
// The $component element cannot be in the xbrli namespace
// if ( $qName->namespaceURI == XBRL_Constants::$standardPrefixes[ STANDARD_PREFIX_XBRLI ] )
// {
// XBRL_Log::getInstance()->instance_validation(
// $componentName == 'scenario'
// ? "4.7.4"
// : "4.7.3.2",
// "A $componentName element cannot be in the xbrl instance namespace",
// array(
// 'context' => $contextId,
// )
// );
// return false;
// }
// Check the member is valid
// Don't look for the element type in the types collection.
// Look for it in the taxonomy element
$taxonomy = $this->getInstanceTaxonomy()->getTaxonomyForNamespace( $qName->namespaceURI );
if ( $taxonomy )
{
$element = $taxonomy->getElementByName( $qName->localName );
if ( ! XBRL_Instance::isEmpty( $element, 'substitutionGroup' ) )
{
if ( $types->resolveToSubstitutionGroup( $element['substitutionGroup'], array( XBRL_Constants::$xbrliItem ) ) )
{
XBRL_Log::getInstance()->instance_validation(
$componentName == 'scenario'
? "4.7.4"
: "4.7.3.2", "A $componentName cannot include an element that is in the xbrli:item substitution group",
array(
'context' => $contextId,
)
);
return false;
}
}
if ( $element && ( ! XBRL_Instance::isEmpty( $element, 'type' ) || isset( $element['types'] ) ) )
{
$type = XBRL_Instance::isEmpty( $element, 'type' )
? ( count( $element['types'] ) ? $element['types'][0] : "" )
: $element['type'];
// If the schema type is a string lookup the type
if ( is_string( $type ) )
{
$qName = qname( $type, $this->instance_namespaces + array( 'xbrli' => XBRL_Constants::$standardPrefixes[ STANDARD_PREFIX_XBRLI ] ) );
$type = $types->getType( $qName->localName, $qName->prefix );
}
if ( is_array( $type ) )
{
if ( isset( $type['values'] ) )
{
// if ( in_array( $component['member'], $type['values'] ) )
if ( in_array( $component['member'], array_map( function( $value ) { return $value['value']; }, $type['values'] ) ) )
{
return true;
}
XBRL_Log::getInstance()->instance_validation(
$componentName == 'scenario'
? "4.7.4"
: "4.7.3.2",
"The $componentName type/member is not valid",
array(
'context' => $contextId,
)
);
return false;
}
else if ( isset( $type['sequence'] ) )
{
echo "seq\n";
}
}
}
}
return true;
} | [
"private",
"function",
"validateNonDimensionMembers",
"(",
"$",
"component",
",",
"$",
"contextId",
",",
"$",
"types",
",",
"$",
"componentName",
",",
"&",
"$",
"data",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"component",
")",
")",
"{",
"XBRL_Log",
"::",... | Used to validate non-dimension segments and scenarios
@param array $component The explicit member information
@param string $contextId The id of the context
@param XBRL_Types $types
@param string $componentName The name of the component: scenario or segment
@param array|null $data An object of data created to pass information between function calls
@return boolean | [
"Used",
"to",
"validate",
"non",
"-",
"dimension",
"segments",
"and",
"scenarios"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Instance.php#L6074-L6175 | train |
bseddon/XBRL | XBRL-Instance.php | XBRL_Instance.getContextDimensions | public function getContextDimensions( $context )
{
if ( isset( $context['entity']['segment'] ) )
return $this->getComponentDimensions( $context['entity']['segment'] );
elseif ( isset( $context['segment'] ) )
return $this->getComponentDimensions( $context['segment'] );
elseif ( isset( $context['entity']['scenario'] ) )
return $this->getComponentDimensions( $context['entity']['scenario'] );
elseif ( isset( $context['scenario'] ) )
return $this->getComponentDimensions( $context['scenario'] );
else
return array();
} | php | public function getContextDimensions( $context )
{
if ( isset( $context['entity']['segment'] ) )
return $this->getComponentDimensions( $context['entity']['segment'] );
elseif ( isset( $context['segment'] ) )
return $this->getComponentDimensions( $context['segment'] );
elseif ( isset( $context['entity']['scenario'] ) )
return $this->getComponentDimensions( $context['entity']['scenario'] );
elseif ( isset( $context['scenario'] ) )
return $this->getComponentDimensions( $context['scenario'] );
else
return array();
} | [
"public",
"function",
"getContextDimensions",
"(",
"$",
"context",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"context",
"[",
"'entity'",
"]",
"[",
"'segment'",
"]",
")",
")",
"return",
"$",
"this",
"->",
"getComponentDimensions",
"(",
"$",
"context",
"[",
... | Get a list of the dimensions and associated member for a context
@param array $context
@return array | [
"Get",
"a",
"list",
"of",
"the",
"dimensions",
"and",
"associated",
"member",
"for",
"a",
"context"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Instance.php#L6197-L6209 | train |
bseddon/XBRL | XBRL-Instance.php | XBRL_Instance.getComponentDimensions | public function getComponentDimensions( $component )
{
$result = array();
if ( isset( $component['explicitMember'] ) )
$dimensions = $component['explicitMember'];
else if ( isset( $component['typedMember'] ) )
$dimensions = $component['typedMember'];
else return $result;
foreach ( $dimensions as $dimension )
{
$result[ $dimension['dimension'] ] = $dimension['member'];
}
return $result;
} | php | public function getComponentDimensions( $component )
{
$result = array();
if ( isset( $component['explicitMember'] ) )
$dimensions = $component['explicitMember'];
else if ( isset( $component['typedMember'] ) )
$dimensions = $component['typedMember'];
else return $result;
foreach ( $dimensions as $dimension )
{
$result[ $dimension['dimension'] ] = $dimension['member'];
}
return $result;
} | [
"public",
"function",
"getComponentDimensions",
"(",
"$",
"component",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"component",
"[",
"'explicitMember'",
"]",
")",
")",
"$",
"dimensions",
"=",
"$",
"component",
"[",... | Get a list of the dimensions and associated member for a scenario or segment context component
@param array $component
@return array | [
"Get",
"a",
"list",
"of",
"the",
"dimensions",
"and",
"associated",
"member",
"for",
"a",
"scenario",
"or",
"segment",
"context",
"component"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Instance.php#L6216-L6232 | train |
bseddon/XBRL | XBRL-Instance.php | XBRL_Instance.isDimensionallyValid | public function isDimensionallyValid( $context, $hypercubeDimensions, $closed )
{
if ( is_string( $context ) )
{
$context = $this->getContext( $context );
}
// The context dimensions must be hypercube dimensions
$contextDimensions = $this->getContextDimensions( $context );
// $hypercubeDimensions = $details['details']['dimensions'];
$invalidDimensions = array_diff_key( $contextDimensions, $hypercubeDimensions );
// If there are any dimensions required by the context that are
// not supported by the hypercube then the context is not valid
if ( $invalidDimensions ) return false;
// The dimension validity must take into account that any
// of the hypercube dimension may have a default member
$validDimensions = array_intersect_key( $contextDimensions, $hypercubeDimensions );
if ( count( $validDimensions ) < count( $hypercubeDimensions ) )
{
// The order of the parameters is important. The result should
// have the missing members of the $reportInfoDimensions array.
$missingDimensions = array_diff_key( $hypercubeDimensions, $validDimensions );
// If there are no defaults an all missing dimensions then lose this context
foreach ( $missingDimensions as $dimensionId => $dimension )
{
if ( ! isset( $dimension['default'] ) ) return false;
}
}
elseif ( count( $contextDimensions ) > count( $hypercubeDimensions ) )
{
// If there are more context dimensions than report info dimensions then the dimension match is wrong
return false;
}
return true;
} | php | public function isDimensionallyValid( $context, $hypercubeDimensions, $closed )
{
if ( is_string( $context ) )
{
$context = $this->getContext( $context );
}
// The context dimensions must be hypercube dimensions
$contextDimensions = $this->getContextDimensions( $context );
// $hypercubeDimensions = $details['details']['dimensions'];
$invalidDimensions = array_diff_key( $contextDimensions, $hypercubeDimensions );
// If there are any dimensions required by the context that are
// not supported by the hypercube then the context is not valid
if ( $invalidDimensions ) return false;
// The dimension validity must take into account that any
// of the hypercube dimension may have a default member
$validDimensions = array_intersect_key( $contextDimensions, $hypercubeDimensions );
if ( count( $validDimensions ) < count( $hypercubeDimensions ) )
{
// The order of the parameters is important. The result should
// have the missing members of the $reportInfoDimensions array.
$missingDimensions = array_diff_key( $hypercubeDimensions, $validDimensions );
// If there are no defaults an all missing dimensions then lose this context
foreach ( $missingDimensions as $dimensionId => $dimension )
{
if ( ! isset( $dimension['default'] ) ) return false;
}
}
elseif ( count( $contextDimensions ) > count( $hypercubeDimensions ) )
{
// If there are more context dimensions than report info dimensions then the dimension match is wrong
return false;
}
return true;
} | [
"public",
"function",
"isDimensionallyValid",
"(",
"$",
"context",
",",
"$",
"hypercubeDimensions",
",",
"$",
"closed",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"context",
")",
")",
"{",
"$",
"context",
"=",
"$",
"this",
"->",
"getContext",
"(",
"$",
... | Tests whether a context is valid for the dimensions of a hypercube
@param array|string $context
@param array $hypercubeDimensions
@param boolean $closed
@return boolean | [
"Tests",
"whether",
"a",
"context",
"is",
"valid",
"for",
"the",
"dimensions",
"of",
"a",
"hypercube"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Instance.php#L6241-L6281 | train |
bseddon/XBRL | XBRL-Instance.php | XBRL_Instance.isHypercubeDimensionallyValid | public function isHypercubeDimensionallyValid( $context, $hypercube, $closed )
{
// Convert the array of dimensions into one indexed by qname as required by the isDimensionallyValid function
$hypercubeDimensions = array_reduce( $hypercube['dimensions'], function( $carry, $dimension ) use( &$hypercubeDimensions )
{
$dimTaxonomy = $this->getInstanceTaxonomy()->getTaxonomyForXSD( $dimension['label'] );
$element = $dimTaxonomy->getElementById( $dimension['label'] );
$carry[ "{$dimTaxonomy->getPrefix()}:{$element['name']}" ] = $dimension;
return $carry;
}, array() );
return $this->isDimensionallyValid( $context, $hypercubeDimensions, $closed );
} | php | public function isHypercubeDimensionallyValid( $context, $hypercube, $closed )
{
// Convert the array of dimensions into one indexed by qname as required by the isDimensionallyValid function
$hypercubeDimensions = array_reduce( $hypercube['dimensions'], function( $carry, $dimension ) use( &$hypercubeDimensions )
{
$dimTaxonomy = $this->getInstanceTaxonomy()->getTaxonomyForXSD( $dimension['label'] );
$element = $dimTaxonomy->getElementById( $dimension['label'] );
$carry[ "{$dimTaxonomy->getPrefix()}:{$element['name']}" ] = $dimension;
return $carry;
}, array() );
return $this->isDimensionallyValid( $context, $hypercubeDimensions, $closed );
} | [
"public",
"function",
"isHypercubeDimensionallyValid",
"(",
"$",
"context",
",",
"$",
"hypercube",
",",
"$",
"closed",
")",
"{",
"// Convert the array of dimensions into one indexed by qname as required by the isDimensionallyValid function\r",
"$",
"hypercubeDimensions",
"=",
"ar... | Tests whether a context is valid for a hypercube
@param array|string $context A context ref or an array for a specific context
@param array $hypercube
@param boolean $closed
@return boolean | [
"Tests",
"whether",
"a",
"context",
"is",
"valid",
"for",
"a",
"hypercube"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Instance.php#L6290-L6303 | train |
bseddon/XBRL | XBRL-Instance.php | XBRL_Instance.isDRSValidForFact | public function isDRSValidForFact( $fact, $drs)
{
foreach ( $drs as $hypercube => $roles )
{
foreach ( $roles as $role => $hypercubeItems )
{
if ( ! isset( $hypercubes[ $hypercube ][ $role ] ) )
{
$closed = isset( $hypercubeItems['parents'][ $fact['label'] ]['closed'] ) && $hypercubeItems['parents'][ $fact['label'] ]['closed'];
if ( ! $this->isHypercubeDimensionallyValid( $fact['contextRef'], $hypercubeItems, $closed ) ) continue;
return true;
}
}
}
return false;
} | php | public function isDRSValidForFact( $fact, $drs)
{
foreach ( $drs as $hypercube => $roles )
{
foreach ( $roles as $role => $hypercubeItems )
{
if ( ! isset( $hypercubes[ $hypercube ][ $role ] ) )
{
$closed = isset( $hypercubeItems['parents'][ $fact['label'] ]['closed'] ) && $hypercubeItems['parents'][ $fact['label'] ]['closed'];
if ( ! $this->isHypercubeDimensionallyValid( $fact['contextRef'], $hypercubeItems, $closed ) ) continue;
return true;
}
}
}
return false;
} | [
"public",
"function",
"isDRSValidForFact",
"(",
"$",
"fact",
",",
"$",
"drs",
")",
"{",
"foreach",
"(",
"$",
"drs",
"as",
"$",
"hypercube",
"=>",
"$",
"roles",
")",
"{",
"foreach",
"(",
"$",
"roles",
"as",
"$",
"role",
"=>",
"$",
"hypercubeItems",
")... | Returns true if ANY hypercube in a DRS is valid for the context
@param array $fact An array for a specific fact
@param array $drs A DRS array returned by a call to getPrimaryItemDRS
@return boolean | [
"Returns",
"true",
"if",
"ANY",
"hypercube",
"in",
"a",
"DRS",
"is",
"valid",
"for",
"the",
"context"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Instance.php#L6311-L6329 | train |
bseddon/XBRL | XBRL-Instance.php | ContextsFilter.getContext | public function getContext( $ref )
{
return isset( $this->contexts[ $ref ] )
? $this->contexts[ $ref ]
: false;
} | php | public function getContext( $ref )
{
return isset( $this->contexts[ $ref ] )
? $this->contexts[ $ref ]
: false;
} | [
"public",
"function",
"getContext",
"(",
"$",
"ref",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"contexts",
"[",
"$",
"ref",
"]",
")",
"?",
"$",
"this",
"->",
"contexts",
"[",
"$",
"ref",
"]",
":",
"false",
";",
"}"
] | Get a specific context by reference
@param string $ref
@return boolean|Array | [
"Get",
"a",
"specific",
"context",
"by",
"reference"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Instance.php#L6383-L6388 | train |
bseddon/XBRL | XBRL-Instance.php | ContextsFilter.getContextsByRef | public function getContextsByRef( $refs )
{
$contexts = array();
if ( is_array( $refs ) )
foreach ( $refs as $ref )
{
if ( ! isset( $this->contexts[ $ref ] ) ) continue;
$contexts[ $ref ] = $this->contexts[ $ref ];
}
return new ContextsFilter( $this->instance, $contexts );
} | php | public function getContextsByRef( $refs )
{
$contexts = array();
if ( is_array( $refs ) )
foreach ( $refs as $ref )
{
if ( ! isset( $this->contexts[ $ref ] ) ) continue;
$contexts[ $ref ] = $this->contexts[ $ref ];
}
return new ContextsFilter( $this->instance, $contexts );
} | [
"public",
"function",
"getContextsByRef",
"(",
"$",
"refs",
")",
"{",
"$",
"contexts",
"=",
"array",
"(",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"refs",
")",
")",
"foreach",
"(",
"$",
"refs",
"as",
"$",
"ref",
")",
"{",
"if",
"(",
"!",
"isset... | Get a set of contexts by reference
@param string $refs
@return ContextsFilter | [
"Get",
"a",
"set",
"of",
"contexts",
"by",
"reference"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Instance.php#L6395-L6407 | train |
bseddon/XBRL | XBRL-Instance.php | ContextsFilter.ContextWithDuration | public function ContextWithDuration( $months )
{
$durationContexts = $this->DurationContexts();
$oneDay = new DateInterval("P1D");
return new ContextsFilter( $instance, array_filter( $durationContexts->getContexts(), function( $context ) use( $months, $oneDay )
{
$interval = date_diff(
new DateTime( $context["period"]["startDate"] ),
(new DateTime( $context["period"]["endDate"] ))->add( $oneDay ) );
return $months == ( $interval->m + ( $interval->y * 12 ) );
} ) );
} | php | public function ContextWithDuration( $months )
{
$durationContexts = $this->DurationContexts();
$oneDay = new DateInterval("P1D");
return new ContextsFilter( $instance, array_filter( $durationContexts->getContexts(), function( $context ) use( $months, $oneDay )
{
$interval = date_diff(
new DateTime( $context["period"]["startDate"] ),
(new DateTime( $context["period"]["endDate"] ))->add( $oneDay ) );
return $months == ( $interval->m + ( $interval->y * 12 ) );
} ) );
} | [
"public",
"function",
"ContextWithDuration",
"(",
"$",
"months",
")",
"{",
"$",
"durationContexts",
"=",
"$",
"this",
"->",
"DurationContexts",
"(",
")",
";",
"$",
"oneDay",
"=",
"new",
"DateInterval",
"(",
"\"P1D\"",
")",
";",
"return",
"new",
"ContextsFilt... | Return context with a specified number of months duration
@param int $months | [
"Return",
"context",
"with",
"a",
"specified",
"number",
"of",
"months",
"duration"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Instance.php#L6473-L6485 | train |
bseddon/XBRL | XBRL-Instance.php | ContextsFilter.EntityContexts | public function EntityContexts( $entity, $scheme = null )
{
$filtered = array_filter( $this->contexts, function ( $context ) use( $entity, $scheme ) {
// The context may be invalid in which case exclude
if ( ! isset( $context['entity']['identifier']['value'] ) ) return false;
if ( $context['entity']['identifier']['value'] == $entity )
{
// If supplied also check the scheme
return $scheme != null && isset( $context['entity']['identifier']['scheme'] )
? ( strtolower( $scheme ) == strtolower( $context['entity']['identifier']['scheme'] ) )
: true;
}
return false;
} );
return new ContextsFilter( $this->instance, $filtered );
} | php | public function EntityContexts( $entity, $scheme = null )
{
$filtered = array_filter( $this->contexts, function ( $context ) use( $entity, $scheme ) {
// The context may be invalid in which case exclude
if ( ! isset( $context['entity']['identifier']['value'] ) ) return false;
if ( $context['entity']['identifier']['value'] == $entity )
{
// If supplied also check the scheme
return $scheme != null && isset( $context['entity']['identifier']['scheme'] )
? ( strtolower( $scheme ) == strtolower( $context['entity']['identifier']['scheme'] ) )
: true;
}
return false;
} );
return new ContextsFilter( $this->instance, $filtered );
} | [
"public",
"function",
"EntityContexts",
"(",
"$",
"entity",
",",
"$",
"scheme",
"=",
"null",
")",
"{",
"$",
"filtered",
"=",
"array_filter",
"(",
"$",
"this",
"->",
"contexts",
",",
"function",
"(",
"$",
"context",
")",
"use",
"(",
"$",
"entity",
",",
... | Returns the context for a specfic entity
@param string $entity The value identifying the entity
@param string $scheme Optionally the scheme associated with the value
@return ContextsFilter | [
"Returns",
"the",
"context",
"for",
"a",
"specfic",
"entity"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Instance.php#L6511-L6530 | train |
bseddon/XBRL | XBRL-Instance.php | ContextsFilter.NoSegmentContexts | public function NoSegmentContexts()
{
$filtered = array_filter( $this->contexts, function( $context ) {
// The context may be invalid in which case exclude
return ( ! isset( $context['entity']['segment']['explicitMember'] ) || count( $context['entity']['segment']['explicitMember'] ) == 0 ) &&
( ! isset( $context['entity']['scenario']['explicitMember'] ) || count( $context['entity']['scenario']['explicitMember'] ) == 0 ) &&
( ! isset( $context['segment']['explicitMember'] ) || count( $context['segment']['explicitMember'] ) == 0 ) &&
( ! isset( $context['scenario']['explicitMember'] ) || count( $context['scenario']['explicitMember'] ) == 0 ) &&
( ! isset( $context['entity']['segment']['typedMember'] ) || count( $context['entity']['segment']['typedMember'] ) == 0 ) &&
( ! isset( $context['entity']['scenario']['typedMember'] ) || count( $context['entity']['scenario']['typedMember'] ) == 0 ) &&
( ! isset( $context['segment']['typedMember'] ) || count( $context['segment']['typedMember'] ) == 0 ) &&
( ! isset( $context['scenario']['typedMember'] ) || count( $context['scenario']['typedMember'] ) == 0 ); } );
return new ContextsFilter( $this->instance, $filtered );
} | php | public function NoSegmentContexts()
{
$filtered = array_filter( $this->contexts, function( $context ) {
// The context may be invalid in which case exclude
return ( ! isset( $context['entity']['segment']['explicitMember'] ) || count( $context['entity']['segment']['explicitMember'] ) == 0 ) &&
( ! isset( $context['entity']['scenario']['explicitMember'] ) || count( $context['entity']['scenario']['explicitMember'] ) == 0 ) &&
( ! isset( $context['segment']['explicitMember'] ) || count( $context['segment']['explicitMember'] ) == 0 ) &&
( ! isset( $context['scenario']['explicitMember'] ) || count( $context['scenario']['explicitMember'] ) == 0 ) &&
( ! isset( $context['entity']['segment']['typedMember'] ) || count( $context['entity']['segment']['typedMember'] ) == 0 ) &&
( ! isset( $context['entity']['scenario']['typedMember'] ) || count( $context['entity']['scenario']['typedMember'] ) == 0 ) &&
( ! isset( $context['segment']['typedMember'] ) || count( $context['segment']['typedMember'] ) == 0 ) &&
( ! isset( $context['scenario']['typedMember'] ) || count( $context['scenario']['typedMember'] ) == 0 ); } );
return new ContextsFilter( $this->instance, $filtered );
} | [
"public",
"function",
"NoSegmentContexts",
"(",
")",
"{",
"$",
"filtered",
"=",
"array_filter",
"(",
"$",
"this",
"->",
"contexts",
",",
"function",
"(",
"$",
"context",
")",
"{",
"// The context may be invalid in which case exclude\r",
"return",
"(",
"!",
"isset"... | Return a list of the contexts without a segment
@return ContextsFilter | [
"Return",
"a",
"list",
"of",
"the",
"contexts",
"without",
"a",
"segment"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Instance.php#L6607-L6621 | train |
bseddon/XBRL | XBRL-Instance.php | ContextsFilter.AllNamespaces | public function AllNamespaces()
{
// In PHP 7.0 $this is passed to closure functions automatically but not in earlier versions
$contexts = &$this->contexts;
$instance = &$this->instance;
$result = array_reduce( array_keys( $this->contexts ), function( $carry, $context ) use( &$contexts, &$instance ) {
// The context may be invalid in which case exclude
if ( ! isset( $contexts[ $context ]['entity']['segment']['explicitMember'] ) || count( $contexts[ $context ]['entity']['segment']['explicitMember'] ) == 0 )
return $carry;
// Each context may have more than one segment. If the filter matches any one segment the context will be included.
$context_segments = $instance->getElementsForContext( $context, true );
foreach ( $context_segments as $key => $segment )
{
if ( ! isset( $segment['dimension']['namespace'] ) || isset( $carry[ $segment['dimension']['namespace'] ] ) ) continue;
$carry[ $segment['dimension']['namespace'] ] = 1;
if ( ! isset( $segment['member']['namespace'] ) || isset( $carry[ $segment['dimension']['namespace'] ] ) ) continue;
$carry[ $segment['member']['namespace'] ] = 1;
}
return $carry;
}, array() );
return array_keys( $result );
} | php | public function AllNamespaces()
{
// In PHP 7.0 $this is passed to closure functions automatically but not in earlier versions
$contexts = &$this->contexts;
$instance = &$this->instance;
$result = array_reduce( array_keys( $this->contexts ), function( $carry, $context ) use( &$contexts, &$instance ) {
// The context may be invalid in which case exclude
if ( ! isset( $contexts[ $context ]['entity']['segment']['explicitMember'] ) || count( $contexts[ $context ]['entity']['segment']['explicitMember'] ) == 0 )
return $carry;
// Each context may have more than one segment. If the filter matches any one segment the context will be included.
$context_segments = $instance->getElementsForContext( $context, true );
foreach ( $context_segments as $key => $segment )
{
if ( ! isset( $segment['dimension']['namespace'] ) || isset( $carry[ $segment['dimension']['namespace'] ] ) ) continue;
$carry[ $segment['dimension']['namespace'] ] = 1;
if ( ! isset( $segment['member']['namespace'] ) || isset( $carry[ $segment['dimension']['namespace'] ] ) ) continue;
$carry[ $segment['member']['namespace'] ] = 1;
}
return $carry;
}, array() );
return array_keys( $result );
} | [
"public",
"function",
"AllNamespaces",
"(",
")",
"{",
"// In PHP 7.0 $this is passed to closure functions automatically but not in earlier versions\r",
"$",
"contexts",
"=",
"&",
"$",
"this",
"->",
"contexts",
";",
"$",
"instance",
"=",
"&",
"$",
"this",
"->",
"instance... | Return an array of all namespaces used by the contexts
@return array of strings | [
"Return",
"an",
"array",
"of",
"all",
"namespaces",
"used",
"by",
"the",
"contexts"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Instance.php#L6627-L6656 | train |
bseddon/XBRL | XBRL-Instance.php | ContextsFilter.AllEntities | public function AllEntities()
{
// In PHP 7.0 $this is passed to closure functions automatically but not in earlier versions
$contexts = &$this->contexts;
$result = array_reduce( array_keys( $this->contexts ), function( $carry, $context ) use( &$contexts ) {
if ( ! isset( $contexts[ $context ]['entity']['identifier']['value'] ) ) return $carry;
/**
* @var \lyquidity\xml\QName $qname
*/
$qname = new QName( null, $contexts[ $context ]['entity']['identifier']['scheme'], $contexts[ $context ]['entity']['identifier']['value'] );
if ( isset( $carry[ $qname->clarkNotation() ] ) ) return $carry;
$carry[ $qname->clarkNotation() ] = 1;
return $carry;
}, array() );
return array_keys( $result );
} | php | public function AllEntities()
{
// In PHP 7.0 $this is passed to closure functions automatically but not in earlier versions
$contexts = &$this->contexts;
$result = array_reduce( array_keys( $this->contexts ), function( $carry, $context ) use( &$contexts ) {
if ( ! isset( $contexts[ $context ]['entity']['identifier']['value'] ) ) return $carry;
/**
* @var \lyquidity\xml\QName $qname
*/
$qname = new QName( null, $contexts[ $context ]['entity']['identifier']['scheme'], $contexts[ $context ]['entity']['identifier']['value'] );
if ( isset( $carry[ $qname->clarkNotation() ] ) ) return $carry;
$carry[ $qname->clarkNotation() ] = 1;
return $carry;
}, array() );
return array_keys( $result );
} | [
"public",
"function",
"AllEntities",
"(",
")",
"{",
"// In PHP 7.0 $this is passed to closure functions automatically but not in earlier versions\r",
"$",
"contexts",
"=",
"&",
"$",
"this",
"->",
"contexts",
";",
"$",
"result",
"=",
"array_reduce",
"(",
"array_keys",
"(",... | Return an array of all entities used by the contexts
@return array of strings | [
"Return",
"an",
"array",
"of",
"all",
"entities",
"used",
"by",
"the",
"contexts"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Instance.php#L6662-L6684 | train |
bseddon/XBRL | XBRL-Instance.php | ContextsFilter.AllExplicitDimensions | public function AllExplicitDimensions()
{
// In PHP 7.0 $this is passed to closure functions automatically but not in earlier versions
$contexts = &$this->contexts;
$namespaces = $this->instance->getInstanceNamespaces();
$result = array_reduce( array_keys( $this->contexts ), function( $carry, $context ) use( &$contexts, &$namespaces )
{
$ctx = $contexts[ $context ];
$explicitMembers = isset( $ctx['entity']['segment']['explicitMember'] )
? $ctx['entity']['segment']['explicitMember']
: ( isset( $ctx['segment']['explicitMember'] )
? $ctx['segment']['explicitMember']
: ( isset( $ctx['entity']['scenario']['explicitMember'] )
? $ctx['entity']['scenario']['explicitMember']
: ( isset( $ctx['scenario']['explicitMember'] )
? $ctx['scenario']['explicitMember']
: null
)
)
);
if ( ! $explicitMembers ) return $carry;
foreach ( $explicitMembers as $explicitMember )
{
$qname = qname( $explicitMember['dimension'], $namespaces );
$carry[ $qname->clarkNotation() ][] = $context;
}
return $carry;
}, array() );
return $result;
} | php | public function AllExplicitDimensions()
{
// In PHP 7.0 $this is passed to closure functions automatically but not in earlier versions
$contexts = &$this->contexts;
$namespaces = $this->instance->getInstanceNamespaces();
$result = array_reduce( array_keys( $this->contexts ), function( $carry, $context ) use( &$contexts, &$namespaces )
{
$ctx = $contexts[ $context ];
$explicitMembers = isset( $ctx['entity']['segment']['explicitMember'] )
? $ctx['entity']['segment']['explicitMember']
: ( isset( $ctx['segment']['explicitMember'] )
? $ctx['segment']['explicitMember']
: ( isset( $ctx['entity']['scenario']['explicitMember'] )
? $ctx['entity']['scenario']['explicitMember']
: ( isset( $ctx['scenario']['explicitMember'] )
? $ctx['scenario']['explicitMember']
: null
)
)
);
if ( ! $explicitMembers ) return $carry;
foreach ( $explicitMembers as $explicitMember )
{
$qname = qname( $explicitMember['dimension'], $namespaces );
$carry[ $qname->clarkNotation() ][] = $context;
}
return $carry;
}, array() );
return $result;
} | [
"public",
"function",
"AllExplicitDimensions",
"(",
")",
"{",
"// In PHP 7.0 $this is passed to closure functions automatically but not in earlier versions\r",
"$",
"contexts",
"=",
"&",
"$",
"this",
"->",
"contexts",
";",
"$",
"namespaces",
"=",
"$",
"this",
"->",
"insta... | Return an array of all explicit dimensions used by the contexts
@return array of strings | [
"Return",
"an",
"array",
"of",
"all",
"explicit",
"dimensions",
"used",
"by",
"the",
"contexts"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Instance.php#L6690-L6725 | train |
bseddon/XBRL | XBRL-Instance.php | ContextsFilter.AllTypedDimensions | public function AllTypedDimensions()
{
// In PHP 7.0 $this is passed to closure functions automatically but not in earlier versions
$contexts = &$this->contexts;
$namespaces = $this->instance->getInstanceNamespaces();
$result = array_reduce( array_keys( $this->contexts ), function( $carry, $context ) use( &$contexts, &$namespaces )
{
$ctx = $contexts[ $context ];
$typedMembers = isset( $ctx['entity']['segment']['typedMember'] )
? $ctx['entity']['segment']['typedMember']
: ( isset( $ctx['segment']['typedMember'] )
? $ctx['segment']['typedMember']
: ( isset( $ctx['entity']['scenario']['typedMember'] )
? $ctx['entity']['scenario']['typedMember']
: ( isset( $ctx['scenario']['typedMember'] )
? $ctx['scenario']['typedMember']
: null
)
)
);
if ( ! $typedMembers ) return $carry;
foreach ( $typedMembers as $typedMember )
{
$qname = qname( $typedMember['dimension'], $namespaces );
$carry[ $qname->clarkNotation() ][] = $context;
}
return $carry;
}, array() );
return $result;
} | php | public function AllTypedDimensions()
{
// In PHP 7.0 $this is passed to closure functions automatically but not in earlier versions
$contexts = &$this->contexts;
$namespaces = $this->instance->getInstanceNamespaces();
$result = array_reduce( array_keys( $this->contexts ), function( $carry, $context ) use( &$contexts, &$namespaces )
{
$ctx = $contexts[ $context ];
$typedMembers = isset( $ctx['entity']['segment']['typedMember'] )
? $ctx['entity']['segment']['typedMember']
: ( isset( $ctx['segment']['typedMember'] )
? $ctx['segment']['typedMember']
: ( isset( $ctx['entity']['scenario']['typedMember'] )
? $ctx['entity']['scenario']['typedMember']
: ( isset( $ctx['scenario']['typedMember'] )
? $ctx['scenario']['typedMember']
: null
)
)
);
if ( ! $typedMembers ) return $carry;
foreach ( $typedMembers as $typedMember )
{
$qname = qname( $typedMember['dimension'], $namespaces );
$carry[ $qname->clarkNotation() ][] = $context;
}
return $carry;
}, array() );
return $result;
} | [
"public",
"function",
"AllTypedDimensions",
"(",
")",
"{",
"// In PHP 7.0 $this is passed to closure functions automatically but not in earlier versions\r",
"$",
"contexts",
"=",
"&",
"$",
"this",
"->",
"contexts",
";",
"$",
"namespaces",
"=",
"$",
"this",
"->",
"instance... | Return an array of all typed dimensions used by the contexts
@return array of strings | [
"Return",
"an",
"array",
"of",
"all",
"typed",
"dimensions",
"used",
"by",
"the",
"contexts"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Instance.php#L6731-L6766 | train |
bseddon/XBRL | XBRL-Instance.php | ContextsFilter.AllYears | public function AllYears()
{
$result = array_reduce( $this->contexts, function( $carry, $context ) {
if ( ! isset( $context['period'] ) ) return $carry;
// Get the year of the start date
$parts = explode( "-", $context['period']['startDate'] );
$carry[ $parts[0] ] = isset( $carry[ $parts[0] ] ) ? $carry[ $parts[0] ] + 1 : 1;
$parts = explode( "-", $context['period']['endDate'] );
$carry[ $parts[0] ] = isset( $carry[ $parts[0] ] ) ? $carry[ $parts[0] ] + 1 : 1;
return $carry;
}, array() );
ksort( $result );
return array_keys( $result );
} | php | public function AllYears()
{
$result = array_reduce( $this->contexts, function( $carry, $context ) {
if ( ! isset( $context['period'] ) ) return $carry;
// Get the year of the start date
$parts = explode( "-", $context['period']['startDate'] );
$carry[ $parts[0] ] = isset( $carry[ $parts[0] ] ) ? $carry[ $parts[0] ] + 1 : 1;
$parts = explode( "-", $context['period']['endDate'] );
$carry[ $parts[0] ] = isset( $carry[ $parts[0] ] ) ? $carry[ $parts[0] ] + 1 : 1;
return $carry;
}, array() );
ksort( $result );
return array_keys( $result );
} | [
"public",
"function",
"AllYears",
"(",
")",
"{",
"$",
"result",
"=",
"array_reduce",
"(",
"$",
"this",
"->",
"contexts",
",",
"function",
"(",
"$",
"carry",
",",
"$",
"context",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"context",
"[",
"'period'",... | Return an array of all years used by the contexts
@return array of strings | [
"Return",
"an",
"array",
"of",
"all",
"years",
"used",
"by",
"the",
"contexts"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Instance.php#L6772-L6788 | train |
bseddon/XBRL | XBRL-Instance.php | ContextsFilter.getSegment | private function getSegment( $context )
{
if ( is_string( $context ) )
{
if ( ! isset( $this->contexts[ $context ] ) ) return null;
$context = $this->contexts[ $context ];
}
if ( isset( $context['segment'] ) ) return $context['segment'];
if ( isset( $context['entity']['segment'] ) ) return $context['entity']['segment'];
return null;
} | php | private function getSegment( $context )
{
if ( is_string( $context ) )
{
if ( ! isset( $this->contexts[ $context ] ) ) return null;
$context = $this->contexts[ $context ];
}
if ( isset( $context['segment'] ) ) return $context['segment'];
if ( isset( $context['entity']['segment'] ) ) return $context['entity']['segment'];
return null;
} | [
"private",
"function",
"getSegment",
"(",
"$",
"context",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"context",
")",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"contexts",
"[",
"$",
"context",
"]",
")",
")",
"return",
"null",
";",
... | Return the available segment element from a context
@param array|string $context
@return array|NULL | [
"Return",
"the",
"available",
"segment",
"element",
"from",
"a",
"context"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Instance.php#L6795-L6807 | train |
bseddon/XBRL | XBRL-Instance.php | ContextsFilter.getScenario | private function getScenario( $context )
{
if ( is_string( $context ) )
{
if ( ! isset( $this->contexts[ $context ] ) ) return null;
$context = $this->contexts[ $context ];
}
if ( isset( $context['scenario'] ) ) return $context['scenario'];
if ( isset( $context['entity']['scenario'] ) ) return $context['entity']['scenario'];
return null;
} | php | private function getScenario( $context )
{
if ( is_string( $context ) )
{
if ( ! isset( $this->contexts[ $context ] ) ) return null;
$context = $this->contexts[ $context ];
}
if ( isset( $context['scenario'] ) ) return $context['scenario'];
if ( isset( $context['entity']['scenario'] ) ) return $context['entity']['scenario'];
return null;
} | [
"private",
"function",
"getScenario",
"(",
"$",
"context",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"context",
")",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"contexts",
"[",
"$",
"context",
"]",
")",
")",
"return",
"null",
";",... | Return the available scenario element from a context
@param array|string $context
@return array|NULL | [
"Return",
"the",
"available",
"scenario",
"element",
"from",
"a",
"context"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Instance.php#L6814-L6826 | train |
bseddon/XBRL | XBRL-Instance.php | ContextsFilter.getPeriodLabel | public function getPeriodLabel()
{
$contexts = $this->contexts; // Protect the contexts
try
{
// If there are only instant context and all the contexts have the same date...
if ( ! $this->DurationContexts()->count() && count( $this->AllYears() ) == 1 )
{
$context = reset( $this->contexts );
return $context['period']['endDate'];
}
else
{
$this->sortByStartDate();
$startContext = reset( $this->contexts );
$this->sortByEndDate();
$endContext = end( $this->contexts );
return "{$startContext['period']['startDate']} - {$endContext['period']['endDate']}";
}
}
finally
{
$this->contexts = $contexts; // Restore
}
} | php | public function getPeriodLabel()
{
$contexts = $this->contexts; // Protect the contexts
try
{
// If there are only instant context and all the contexts have the same date...
if ( ! $this->DurationContexts()->count() && count( $this->AllYears() ) == 1 )
{
$context = reset( $this->contexts );
return $context['period']['endDate'];
}
else
{
$this->sortByStartDate();
$startContext = reset( $this->contexts );
$this->sortByEndDate();
$endContext = end( $this->contexts );
return "{$startContext['period']['startDate']} - {$endContext['period']['endDate']}";
}
}
finally
{
$this->contexts = $contexts; // Restore
}
} | [
"public",
"function",
"getPeriodLabel",
"(",
")",
"{",
"$",
"contexts",
"=",
"$",
"this",
"->",
"contexts",
";",
"// Protect the contexts\r",
"try",
"{",
"// If there are only instant context and all the contexts have the same date...\r",
"if",
"(",
"!",
"$",
"this",
"-... | Return a period label for the context collection
@return string | [
"Return",
"a",
"period",
"label",
"for",
"the",
"context",
"collection"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Instance.php#L6832-L6856 | train |
bseddon/XBRL | XBRL-Instance.php | ContextsFilter.remove | public function remove( $contexts )
{
if ( is_string( $contexts ) )
{
unset( $this->contexts[ $contexts ] );
}
else if ( $contexts instanceof ContextsFilter )
{
$contexts = array_keys( $contexts->getContexts() );
}
if ( is_array( $contexts ) )
{
foreach ( $contexts as $context )
{
unset( $this->contexts[ $context ] );
}
}
return $this;
} | php | public function remove( $contexts )
{
if ( is_string( $contexts ) )
{
unset( $this->contexts[ $contexts ] );
}
else if ( $contexts instanceof ContextsFilter )
{
$contexts = array_keys( $contexts->getContexts() );
}
if ( is_array( $contexts ) )
{
foreach ( $contexts as $context )
{
unset( $this->contexts[ $context ] );
}
}
return $this;
} | [
"public",
"function",
"remove",
"(",
"$",
"contexts",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"contexts",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"contexts",
"[",
"$",
"contexts",
"]",
")",
";",
"}",
"else",
"if",
"(",
"$",
"contexts",
... | Remove one or more contexts. The instance will be changed and will be removed.
@param string|string[]|ContextFilter $contexts
@return ContextsFilter | [
"Remove",
"one",
"or",
"more",
"contexts",
".",
"The",
"instance",
"will",
"be",
"changed",
"and",
"will",
"be",
"removed",
"."
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Instance.php#L6907-L6927 | train |
bseddon/XBRL | XBRL-Instance.php | InstanceElementsFilter.ElementsByName | public function ElementsByName( $names )
{
if ( is_string( $names ) )
$names = array_map( 'trim', explode( ",", $names ) );
if ( ! is_array( $names ) )
throw new Exception( 'InstanceElementsFilter::ElementsByName $names must be a string or array' );
$names = array_flip( $names );
return new InstanceElementsFilter( $this->instance, array_intersect_key( $this->elements, $names ) );
} | php | public function ElementsByName( $names )
{
if ( is_string( $names ) )
$names = array_map( 'trim', explode( ",", $names ) );
if ( ! is_array( $names ) )
throw new Exception( 'InstanceElementsFilter::ElementsByName $names must be a string or array' );
$names = array_flip( $names );
return new InstanceElementsFilter( $this->instance, array_intersect_key( $this->elements, $names ) );
} | [
"public",
"function",
"ElementsByName",
"(",
"$",
"names",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"names",
")",
")",
"$",
"names",
"=",
"array_map",
"(",
"'trim'",
",",
"explode",
"(",
"\",\"",
",",
"$",
"names",
")",
")",
";",
"if",
"(",
"!",... | Return a list of elements filtered by one or more names
@param array|string $names The parameter can be the name of an element, a comma delimited list of names or an array of names
@throws Exception
@return InstanceElementsFilter | [
"Return",
"a",
"list",
"of",
"elements",
"filtered",
"by",
"one",
"or",
"more",
"names"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Instance.php#L7038-L7048 | train |
bseddon/XBRL | XBRL-Instance.php | InstanceElementsFilter.ElementsByContexts | 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 );
} | 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... | 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"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Instance.php#L7056-L7105 | train |
bseddon/XBRL | XBRL-Instance.php | InstanceElementsFilter.ElementsByNamespaces | public function ElementsByNamespaces( $namespaces )
{
if ( is_string( $namespaces ) )
$namespaces = array_map( 'trim', explode( ",", $namespaces ) );
if ( ! is_array( $namespaces ) )
throw new Exception( 'InstanceElementsFilter::ElementsByName $namespaces must be a string or array' );
$namespaces = array_flip( array_map( 'strtolower', $namespaces ) );
$instance_namespaces = $this->instance->getInstanceNamespaces();
// 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( &$elements, $instance_namespaces, $namespaces ) {
$namespaceElements = array_filter( $elements[ $elementName ], function( $entry ) use( &$elements, $instance_namespaces, $namespaces ) {
$namespace = isset( $instance_namespaces[ $entry['namespace'] ] ) ? $instance_namespaces[ $entry['namespace'] ] : $entry['namespace'];
return isset( $namespaces[ strtolower( $namespace ) ] );
} );
if ( ! $namespaceElements ) return $carry;
$carry[ $elementName ] = $namespaceElements;
return $carry;
}, array() );
return new InstanceElementsFilter( $this->instance, $filtered );
} | php | public function ElementsByNamespaces( $namespaces )
{
if ( is_string( $namespaces ) )
$namespaces = array_map( 'trim', explode( ",", $namespaces ) );
if ( ! is_array( $namespaces ) )
throw new Exception( 'InstanceElementsFilter::ElementsByName $namespaces must be a string or array' );
$namespaces = array_flip( array_map( 'strtolower', $namespaces ) );
$instance_namespaces = $this->instance->getInstanceNamespaces();
// 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( &$elements, $instance_namespaces, $namespaces ) {
$namespaceElements = array_filter( $elements[ $elementName ], function( $entry ) use( &$elements, $instance_namespaces, $namespaces ) {
$namespace = isset( $instance_namespaces[ $entry['namespace'] ] ) ? $instance_namespaces[ $entry['namespace'] ] : $entry['namespace'];
return isset( $namespaces[ strtolower( $namespace ) ] );
} );
if ( ! $namespaceElements ) return $carry;
$carry[ $elementName ] = $namespaceElements;
return $carry;
}, array() );
return new InstanceElementsFilter( $this->instance, $filtered );
} | [
"public",
"function",
"ElementsByNamespaces",
"(",
"$",
"namespaces",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"namespaces",
")",
")",
"$",
"namespaces",
"=",
"array_map",
"(",
"'trim'",
",",
"explode",
"(",
"\",\"",
",",
"$",
"namespaces",
")",
")",
... | Return a list of elements based on a set of namespaces
@param array|string $namespaces The parameter can be the name of an namespace, a comma delimited list of namespaces or an array of namespaces
@throws Exception
@return InstanceElementsFilter | [
"Return",
"a",
"list",
"of",
"elements",
"based",
"on",
"a",
"set",
"of",
"namespaces"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Instance.php#L7113-L7144 | train |
bseddon/XBRL | XBRL-Instance.php | InstanceElementsFilter.ElementsByItemType | public function ElementsByItemType( $types )
{
if ( is_string( $types ) )
$types = array_map( 'trim', explode( ",", $types ) );
if ( ! is_array( $types ) )
throw new Exception( 'InstanceElementsFilter::ElementsByName $types must be a string or array' );
$types = array_flip( array_map( 'strtolower', $types ) );
// 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( &$elements, $types ) {
$namespaceElements = array_filter( $elements[ $elementName ], function( $entry ) use( $types ) {
$type = $entry['taxonomy_element']['type'];
return isset( $types[ strtolower( $type ) ] );
} );
if ( ! $namespaceElements ) return $carry;
$carry[ $elementName ] = $namespaceElements;
return $carry;
}, array() );
return new InstanceElementsFilter( $this->instance, $filtered );
} | php | public function ElementsByItemType( $types )
{
if ( is_string( $types ) )
$types = array_map( 'trim', explode( ",", $types ) );
if ( ! is_array( $types ) )
throw new Exception( 'InstanceElementsFilter::ElementsByName $types must be a string or array' );
$types = array_flip( array_map( 'strtolower', $types ) );
// 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( &$elements, $types ) {
$namespaceElements = array_filter( $elements[ $elementName ], function( $entry ) use( $types ) {
$type = $entry['taxonomy_element']['type'];
return isset( $types[ strtolower( $type ) ] );
} );
if ( ! $namespaceElements ) return $carry;
$carry[ $elementName ] = $namespaceElements;
return $carry;
}, array() );
return new InstanceElementsFilter( $this->instance, $filtered );
} | [
"public",
"function",
"ElementsByItemType",
"(",
"$",
"types",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"types",
")",
")",
"$",
"types",
"=",
"array_map",
"(",
"'trim'",
",",
"explode",
"(",
"\",\"",
",",
"$",
"types",
")",
")",
";",
"if",
"(",
... | Return a list of elements based on a set of item types
@param array|string $types The parameter can be the name of a item type, a comma delimited list of item types or an array of item types
@throws Exception
@return InstanceElementsFilter | [
"Return",
"a",
"list",
"of",
"elements",
"based",
"on",
"a",
"set",
"of",
"item",
"types"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Instance.php#L7152-L7181 | train |
bseddon/XBRL | XBRL-Instance.php | InstanceElementsFilter.getNamespaces | public function getNamespaces()
{
$namespaces = $this->instance->getInstanceNamespaces();
$usedNamespaces = array_reduce( $this->elements, function( $carry, $element ) use( $namespaces ) {
foreach ( $element as $key => $entry )
{
$namespace = isset( $namespaces[ $entry['namespace'] ] ) ? $namespaces[ $entry['namespace'] ] : $entry['namespace'];
if ( ! isset( $carry[ $namespace ] ) )
$carry[ $namespace ] = 1;
}
return $carry;
}, array() );
return array_keys( $usedNamespaces );
} | php | public function getNamespaces()
{
$namespaces = $this->instance->getInstanceNamespaces();
$usedNamespaces = array_reduce( $this->elements, function( $carry, $element ) use( $namespaces ) {
foreach ( $element as $key => $entry )
{
$namespace = isset( $namespaces[ $entry['namespace'] ] ) ? $namespaces[ $entry['namespace'] ] : $entry['namespace'];
if ( ! isset( $carry[ $namespace ] ) )
$carry[ $namespace ] = 1;
}
return $carry;
}, array() );
return array_keys( $usedNamespaces );
} | [
"public",
"function",
"getNamespaces",
"(",
")",
"{",
"$",
"namespaces",
"=",
"$",
"this",
"->",
"instance",
"->",
"getInstanceNamespaces",
"(",
")",
";",
"$",
"usedNamespaces",
"=",
"array_reduce",
"(",
"$",
"this",
"->",
"elements",
",",
"function",
"(",
... | Return a list of the namespaces used by the elements
@return array | [
"Return",
"a",
"list",
"of",
"the",
"namespaces",
"used",
"by",
"the",
"elements"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Instance.php#L7187-L7204 | train |
bseddon/XBRL | XBRL-Instance.php | InstanceElementsFilter.getSubstitutionGroups | public function getSubstitutionGroups()
{
$usedGroups = array_reduce( $this->elements, function( $carry, $element ) {
foreach ( $element as $key => $entry )
{
$group = $entry['taxonomy_element']['substitutionGroup'];
if ( ! isset( $carry[ $group ] ) )
$carry[ $group ] = 1;
}
return $carry;
}, array() );
return array_keys( $usedGroups );
} | php | public function getSubstitutionGroups()
{
$usedGroups = array_reduce( $this->elements, function( $carry, $element ) {
foreach ( $element as $key => $entry )
{
$group = $entry['taxonomy_element']['substitutionGroup'];
if ( ! isset( $carry[ $group ] ) )
$carry[ $group ] = 1;
}
return $carry;
}, array() );
return array_keys( $usedGroups );
} | [
"public",
"function",
"getSubstitutionGroups",
"(",
")",
"{",
"$",
"usedGroups",
"=",
"array_reduce",
"(",
"$",
"this",
"->",
"elements",
",",
"function",
"(",
"$",
"carry",
",",
"$",
"element",
")",
"{",
"foreach",
"(",
"$",
"element",
"as",
"$",
"key",... | Return a list of the substitution groups used by the elements
@return array | [
"Return",
"a",
"list",
"of",
"the",
"substitution",
"groups",
"used",
"by",
"the",
"elements"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Instance.php#L7210-L7225 | train |
bseddon/XBRL | XBRL-Instance.php | InstanceElementsFilter.getItemTypes | public function getItemTypes()
{
$usedTypes = array_reduce( $this->elements, function( $carry, $element ) {
foreach ( $element as $key => $entry )
{
$type = $entry['taxonomy_element']['type'];
if ( empty( $type ) ) continue;
if ( ! isset( $carry[ $type ] ) )
{
$carry[ $type ] = 1;
}
}
return $carry;
}, array() );
return array_keys( $usedTypes );
} | php | public function getItemTypes()
{
$usedTypes = array_reduce( $this->elements, function( $carry, $element ) {
foreach ( $element as $key => $entry )
{
$type = $entry['taxonomy_element']['type'];
if ( empty( $type ) ) continue;
if ( ! isset( $carry[ $type ] ) )
{
$carry[ $type ] = 1;
}
}
return $carry;
}, array() );
return array_keys( $usedTypes );
} | [
"public",
"function",
"getItemTypes",
"(",
")",
"{",
"$",
"usedTypes",
"=",
"array_reduce",
"(",
"$",
"this",
"->",
"elements",
",",
"function",
"(",
"$",
"carry",
",",
"$",
"element",
")",
"{",
"foreach",
"(",
"$",
"element",
"as",
"$",
"key",
"=>",
... | Return a list of the types used by the elements
@return array | [
"Return",
"a",
"list",
"of",
"the",
"types",
"used",
"by",
"the",
"elements"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Instance.php#L7231-L7249 | train |
bseddon/XBRL | XBRL-Instance.php | InstanceElementsFilter.UniqueElementEntries | public function UniqueElementEntries()
{
$result = array(); // Build a new array
foreach ( $this->elements as $name => $entries )
{
if ( ! isset( $result[ $name ] ) ) $result[ $name ] = array();
foreach ( $entries as $key => $entry )
{
if ( isset( $entry['tuple_elements'] ) )
{
// Just take it
$result[ $name ][] = $entry;
continue;
}
if ( $this->entry_is_unique( $result[ $name ], $entry ) )
$result[ $name ][] = $entry;
}
}
return new InstanceElementsFilter( $this, $result );
} | php | public function UniqueElementEntries()
{
$result = array(); // Build a new array
foreach ( $this->elements as $name => $entries )
{
if ( ! isset( $result[ $name ] ) ) $result[ $name ] = array();
foreach ( $entries as $key => $entry )
{
if ( isset( $entry['tuple_elements'] ) )
{
// Just take it
$result[ $name ][] = $entry;
continue;
}
if ( $this->entry_is_unique( $result[ $name ], $entry ) )
$result[ $name ][] = $entry;
}
}
return new InstanceElementsFilter( $this, $result );
} | [
"public",
"function",
"UniqueElementEntries",
"(",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"// Build a new array\r",
"foreach",
"(",
"$",
"this",
"->",
"elements",
"as",
"$",
"name",
"=>",
"$",
"entries",
")",
"{",
"if",
"(",
"!",
"isset",
... | Reduce elements so they only have unique entries
@return InstanceElementsFilter | [
"Reduce",
"elements",
"so",
"they",
"only",
"have",
"unique",
"entries"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Instance.php#L7255-L7278 | train |
bseddon/XBRL | XBRL-TaxonomyPackage.php | XBRL_TaxonomyPackage.getFileAsXML | public function getFileAsXML( $path )
{
try
{
$xml = $this->getFile( $this->getActualUri( $path ) );
isXml( $xml );
return simplexml_load_string( $xml );
}
catch ( Exception $ex )
{
throw XBRL_TaxonomyPackageException::withError( "tpe:invalidMetaDataFile", $ex->getMessage() );
}
} | php | public function getFileAsXML( $path )
{
try
{
$xml = $this->getFile( $this->getActualUri( $path ) );
isXml( $xml );
return simplexml_load_string( $xml );
}
catch ( Exception $ex )
{
throw XBRL_TaxonomyPackageException::withError( "tpe:invalidMetaDataFile", $ex->getMessage() );
}
} | [
"public",
"function",
"getFileAsXML",
"(",
"$",
"path",
")",
"{",
"try",
"{",
"$",
"xml",
"=",
"$",
"this",
"->",
"getFile",
"(",
"$",
"this",
"->",
"getActualUri",
"(",
"$",
"path",
")",
")",
";",
"isXml",
"(",
"$",
"xml",
")",
";",
"return",
"s... | Return the contents of a file given a path
@param string $path
@return SimpleXMLElement
@throws Exception if the requested file does not exist | [
"Return",
"the",
"contents",
"of",
"a",
"file",
"given",
"a",
"path"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-TaxonomyPackage.php#L544-L556 | train |
bseddon/XBRL | XBRL-TaxonomyPackage.php | XBRL_TaxonomyPackage.getAllEntryPoint | public function getAllEntryPoint()
{
$entryPoints = $this->getSchemaEntryPoints();
$alls = array_filter( $entryPoints, function( $entryPoint ) { return strpos( $entryPoint, "entryAll" ) !== false; } );
return $alls ? reset( $alls ) : false;
} | php | public function getAllEntryPoint()
{
$entryPoints = $this->getSchemaEntryPoints();
$alls = array_filter( $entryPoints, function( $entryPoint ) { return strpos( $entryPoint, "entryAll" ) !== false; } );
return $alls ? reset( $alls ) : false;
} | [
"public",
"function",
"getAllEntryPoint",
"(",
")",
"{",
"$",
"entryPoints",
"=",
"$",
"this",
"->",
"getSchemaEntryPoints",
"(",
")",
";",
"$",
"alls",
"=",
"array_filter",
"(",
"$",
"entryPoints",
",",
"function",
"(",
"$",
"entryPoint",
")",
"{",
"retur... | Return the url for the 'all' entry point | [
"Return",
"the",
"url",
"for",
"the",
"all",
"entry",
"point"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-TaxonomyPackage.php#L598-L603 | train |
bseddon/XBRL | XBRL-Equality.php | XBRL_Equality.attribute_equal | public static function attribute_equal( $value1, $value2, $type1, $type2, &$namespaces, &$types = null )
{
$qname1 = qname( $value1, $namespaces );
$qname2 = qname( $value2, $namespaces );
if ( ! is_null( $qname1 ) && ! is_null( $qname1 ) )
{
// The qnames should be equivalent
if ( ! $qname1->equals( $qname2 ) ) return false;
$value1 = $qname1->localName;
$value2 = $qname1->localName;
}
else if ( is_null( $qname1 ) || is_null( $qname1 ) )
{
return false;
}
return XBRL_Equality::xequal( $value1, $value2, $type1, $type2, $types );
} | php | public static function attribute_equal( $value1, $value2, $type1, $type2, &$namespaces, &$types = null )
{
$qname1 = qname( $value1, $namespaces );
$qname2 = qname( $value2, $namespaces );
if ( ! is_null( $qname1 ) && ! is_null( $qname1 ) )
{
// The qnames should be equivalent
if ( ! $qname1->equals( $qname2 ) ) return false;
$value1 = $qname1->localName;
$value2 = $qname1->localName;
}
else if ( is_null( $qname1 ) || is_null( $qname1 ) )
{
return false;
}
return XBRL_Equality::xequal( $value1, $value2, $type1, $type2, $types );
} | [
"public",
"static",
"function",
"attribute_equal",
"(",
"$",
"value1",
",",
"$",
"value2",
",",
"$",
"type1",
",",
"$",
"type2",
",",
"&",
"$",
"namespaces",
",",
"&",
"$",
"types",
"=",
"null",
")",
"{",
"$",
"qname1",
"=",
"qname",
"(",
"$",
"val... | The two attributes have local names and namespaces that are S-Equal and have values that are X-Equal
@param string $value1 An attribute in the form 'localname' or 'prefix:localname'
@param string $value2 An attribute in the form 'localname' or 'prefix:localname'
@param string $type1 The type of $value1 (default: XBRL_Equality::$EQUALITY_TYPE_STRING)
@param string $type2 The type of $value2 (default: XBRL_Equality::$EQUALITY_TYPE_STRING)
@param array $namespaces A list of namespaces indexed by prefix from the current document
@param XBRL_Types $types A reference to an XBRL_Types instance
@return bool | [
"The",
"two",
"attributes",
"have",
"local",
"names",
"and",
"namespaces",
"that",
"are",
"S",
"-",
"Equal",
"and",
"have",
"values",
"that",
"are",
"X",
"-",
"Equal"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Equality.php#L101-L120 | train |
bseddon/XBRL | XBRL-Equality.php | XBRL_Equality.divide_equal | public static function divide_equal( $d1, $d2, &$types, &$namespaces )
{
if ( is_null( $d1 ) && is_null( $d2 ) ) return true;
if ( is_null( $d1 ) || is_null( $d2 ) ) return false;
// Check the arrays have the same elements
$result = XBRL_Equality::matchedKeyNames( $d1, $d2, array( 'denominator', 'numerator' ) );
// if ( $result === false || ! is_array( $result ) || ! count( $result ) ) return false;
if ( $result === false || ! is_array( $result ) ) return false;
if ( ! count( $result ) ) return true;
foreach ( $result as $elementName )
{
switch ( $elementName )
{
case 'denominator':
if ( ! XBRL_Equality::measures_equal( $d1['denominator'], $d2['denominator'], $types, $namespaces ) )
{
return false;
}
break;
case 'numerator':
if ( ! XBRL_Equality::measures_equal( $d1['numerator'], $d2['numerator'], $types, $namespaces ) )
{
return false;
}
break;
}
}
return true;
} | php | public static function divide_equal( $d1, $d2, &$types, &$namespaces )
{
if ( is_null( $d1 ) && is_null( $d2 ) ) return true;
if ( is_null( $d1 ) || is_null( $d2 ) ) return false;
// Check the arrays have the same elements
$result = XBRL_Equality::matchedKeyNames( $d1, $d2, array( 'denominator', 'numerator' ) );
// if ( $result === false || ! is_array( $result ) || ! count( $result ) ) return false;
if ( $result === false || ! is_array( $result ) ) return false;
if ( ! count( $result ) ) return true;
foreach ( $result as $elementName )
{
switch ( $elementName )
{
case 'denominator':
if ( ! XBRL_Equality::measures_equal( $d1['denominator'], $d2['denominator'], $types, $namespaces ) )
{
return false;
}
break;
case 'numerator':
if ( ! XBRL_Equality::measures_equal( $d1['numerator'], $d2['numerator'], $types, $namespaces ) )
{
return false;
}
break;
}
}
return true;
} | [
"public",
"static",
"function",
"divide_equal",
"(",
"$",
"d1",
",",
"$",
"d2",
",",
"&",
"$",
"types",
",",
"&",
"$",
"namespaces",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"d1",
")",
"&&",
"is_null",
"(",
"$",
"d2",
")",
")",
"return",
"true",... | Make sure divide definitions are equal
@param array $d1 An array of numerator and denominator elements
@param array $d2 An array of numerator and denominator elements
@param array $types A reference to the global XBRL_Types instance
@param array $namespaces A list of the namespaces in the current document
@return false|array | [
"Make",
"sure",
"divide",
"definitions",
"are",
"equal"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Equality.php#L187-L224 | train |
bseddon/XBRL | XBRL-Equality.php | XBRL_Equality.unit_equal | public static function unit_equal( $u1, $u2, &$types, &$namespaces )
{
if ( is_null( $u1 ) && is_null( $u2 ) ) return true;
if ( is_null( $u1 ) || is_null( $u2 ) ) return false;
// If one value is an array (divide) they must *both* be array.
// If one value is a string (measure) they MUST *both* be string.
if ( is_string( $u1 ) && is_string( $u2 ) )
{
// It's a string so it's a measure
return XBRL_Equality::attribute_equal( $u1, $u2, XBRL_Equality::$EQUALITY_TYPE_STRING, XBRL_Equality::$EQUALITY_TYPE_STRING, $namespaces, $types );
}
if ( ! is_array( $u1 ) || ! is_array( $u2 ) )
{
return false;
}
// Check the arrays have the same elements
$result = XBRL_Equality::matchedKeyNames( $u1, $u2, array( 'divide', 'measures' ) );
if ( $result === false || ! is_array( $result ) ) return false;
if ( ! count( $result ) ) return true;
foreach ( $result as $elementName )
{
// There will be a divide or there will be measures
switch ( $elementName )
{
case 'divide':
if ( ! XBRL_Equality::divide_equal( $u1['divide'], $u2['divide'], $types, $namespaces ) )
{
return false;
}
break;
case 'measures':
if ( ! XBRL_Equality::measures_equal( $u1['measures'], $u2['measures'], $types, $namespaces ) )
{
return false;
}
break;
}
}
return true;
} | php | public static function unit_equal( $u1, $u2, &$types, &$namespaces )
{
if ( is_null( $u1 ) && is_null( $u2 ) ) return true;
if ( is_null( $u1 ) || is_null( $u2 ) ) return false;
// If one value is an array (divide) they must *both* be array.
// If one value is a string (measure) they MUST *both* be string.
if ( is_string( $u1 ) && is_string( $u2 ) )
{
// It's a string so it's a measure
return XBRL_Equality::attribute_equal( $u1, $u2, XBRL_Equality::$EQUALITY_TYPE_STRING, XBRL_Equality::$EQUALITY_TYPE_STRING, $namespaces, $types );
}
if ( ! is_array( $u1 ) || ! is_array( $u2 ) )
{
return false;
}
// Check the arrays have the same elements
$result = XBRL_Equality::matchedKeyNames( $u1, $u2, array( 'divide', 'measures' ) );
if ( $result === false || ! is_array( $result ) ) return false;
if ( ! count( $result ) ) return true;
foreach ( $result as $elementName )
{
// There will be a divide or there will be measures
switch ( $elementName )
{
case 'divide':
if ( ! XBRL_Equality::divide_equal( $u1['divide'], $u2['divide'], $types, $namespaces ) )
{
return false;
}
break;
case 'measures':
if ( ! XBRL_Equality::measures_equal( $u1['measures'], $u2['measures'], $types, $namespaces ) )
{
return false;
}
break;
}
}
return true;
} | [
"public",
"static",
"function",
"unit_equal",
"(",
"$",
"u1",
",",
"$",
"u2",
",",
"&",
"$",
"types",
",",
"&",
"$",
"namespaces",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"u1",
")",
"&&",
"is_null",
"(",
"$",
"u2",
")",
")",
"return",
"true",
... | Make sure unit definitions are equal
@param array $u1
@param array $u2
@param array $types A reference to the global XBRL_Types instance
@param array $namespaces A list of the namespaces in the current document
@return false|array | [
"Make",
"sure",
"unit",
"definitions",
"are",
"equal"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Equality.php#L471-L522 | train |
bseddon/XBRL | XBRL-Equality.php | XBRL_Equality.compare_arrays | public static function compare_arrays( $value1, $value2 )
{
if ( count( $value1 ) != count( $value2 ) ) return false;
$types = XBRL_Types::getInstance();
foreach ( $value1 as $key => $value )
{
if ( ! isset( $value2[ $key ] ) ) return false;
if ( $key == 'id' )
{
$pattern = "/^" . SchemaTypes::$ncName . "$/u";
if ( ! preg_match( $pattern, $value, $matches ) )
{
$this->log()->taxonomy_validation( "context", "id attribute is not a valid NCName", array( 'id' => $value ) );
}
if ( ! preg_match( $pattern, $value2[ $key ], $matches ) )
{
$this->log()->taxonomy_validation( "context", "id attribute is not a valid NCName", array( 'id' => $value[ $key ] ) );
}
}
if ( is_array( $value ) )
{
if ( ! is_array( $value2[ $key ] ) ) return false;
// These arrays will represent a collection of elements (the key will be 'children') so compare them in order
if ( ! XBRL_Equality::compare_arrays_ordinal( $value, $value2[ $key ]) )
{
return false;
}
continue;
}
else if ( in_array( $key, array( 'id', 'name', 'prefix', 'type' ) ) )
{
if ( $value != $value2[ $key ] )
{
return false;
}
continue;
}
// These can be attribute comparisons so if not the element value look for an attribute and get the type
$aType = $key == 'value'
? XBRL_Equality::xequalElementType( $types, $value1['name'], isset( $value1['prefix'] ) ? $value1['prefix'] : null )
: XBRL_Equality::xequalAttributeType( $types, $key, isset( $value1['prefix'] ) ? $value1['prefix'] : null );
$bType = $key == 'value'
? XBRL_Equality::xequalElementType( $types, $value2['name'], isset( $value2['prefix'] ) ? $value2['prefix'] : null )
: XBRL_Equality::xequalAttributeType( $types, $key, isset( $value2['prefix'] ) ? $value2['prefix'] : null );
if ( ! XBRL_Equality::xequal( $value, $value2[ $key ], $aType, $bType, $types ) )
{
return false;
}
}
return true;
} | php | public static function compare_arrays( $value1, $value2 )
{
if ( count( $value1 ) != count( $value2 ) ) return false;
$types = XBRL_Types::getInstance();
foreach ( $value1 as $key => $value )
{
if ( ! isset( $value2[ $key ] ) ) return false;
if ( $key == 'id' )
{
$pattern = "/^" . SchemaTypes::$ncName . "$/u";
if ( ! preg_match( $pattern, $value, $matches ) )
{
$this->log()->taxonomy_validation( "context", "id attribute is not a valid NCName", array( 'id' => $value ) );
}
if ( ! preg_match( $pattern, $value2[ $key ], $matches ) )
{
$this->log()->taxonomy_validation( "context", "id attribute is not a valid NCName", array( 'id' => $value[ $key ] ) );
}
}
if ( is_array( $value ) )
{
if ( ! is_array( $value2[ $key ] ) ) return false;
// These arrays will represent a collection of elements (the key will be 'children') so compare them in order
if ( ! XBRL_Equality::compare_arrays_ordinal( $value, $value2[ $key ]) )
{
return false;
}
continue;
}
else if ( in_array( $key, array( 'id', 'name', 'prefix', 'type' ) ) )
{
if ( $value != $value2[ $key ] )
{
return false;
}
continue;
}
// These can be attribute comparisons so if not the element value look for an attribute and get the type
$aType = $key == 'value'
? XBRL_Equality::xequalElementType( $types, $value1['name'], isset( $value1['prefix'] ) ? $value1['prefix'] : null )
: XBRL_Equality::xequalAttributeType( $types, $key, isset( $value1['prefix'] ) ? $value1['prefix'] : null );
$bType = $key == 'value'
? XBRL_Equality::xequalElementType( $types, $value2['name'], isset( $value2['prefix'] ) ? $value2['prefix'] : null )
: XBRL_Equality::xequalAttributeType( $types, $key, isset( $value2['prefix'] ) ? $value2['prefix'] : null );
if ( ! XBRL_Equality::xequal( $value, $value2[ $key ], $aType, $bType, $types ) )
{
return false;
}
}
return true;
} | [
"public",
"static",
"function",
"compare_arrays",
"(",
"$",
"value1",
",",
"$",
"value2",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"value1",
")",
"!=",
"count",
"(",
"$",
"value2",
")",
")",
"return",
"false",
";",
"$",
"types",
"=",
"XBRL_Types",
"::... | Compare arrays ignoring the position of the elements
@param array $value1
@param array $value2
@return bool | [
"Compare",
"arrays",
"ignoring",
"the",
"position",
"of",
"the",
"elements"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Equality.php#L681-L743 | train |
bseddon/XBRL | XBRL-Equality.php | XBRL_Equality.xequalAttributeType | public static function xequalAttributeType( $types, $localName, $prefix )
{
$attribute = $types->getAttribute( $localName, $prefix );
if ( ! $attribute || ! isset( $attribute['types'] ) || ! count( $attribute['types'] ) ) return XBRL_Equality::$EQUALITY_TYPE_STRING;
return XBRL_Equality::xEqualComparisonType( array( 'type' => $attribute['types'][0] ), $types);
} | php | public static function xequalAttributeType( $types, $localName, $prefix )
{
$attribute = $types->getAttribute( $localName, $prefix );
if ( ! $attribute || ! isset( $attribute['types'] ) || ! count( $attribute['types'] ) ) return XBRL_Equality::$EQUALITY_TYPE_STRING;
return XBRL_Equality::xEqualComparisonType( array( 'type' => $attribute['types'][0] ), $types);
} | [
"public",
"static",
"function",
"xequalAttributeType",
"(",
"$",
"types",
",",
"$",
"localName",
",",
"$",
"prefix",
")",
"{",
"$",
"attribute",
"=",
"$",
"types",
"->",
"getAttribute",
"(",
"$",
"localName",
",",
"$",
"prefix",
")",
";",
"if",
"(",
"!... | Get the xequal comparison type an attribute
@param XBRL_Types $types
@param string $localName
@param string|null $prefix
@return number | [
"Get",
"the",
"xequal",
"comparison",
"type",
"an",
"attribute"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Equality.php#L752-L758 | train |
bseddon/XBRL | XBRL-Equality.php | XBRL_Equality.xequalElementType | private static function xequalElementType( $types, $localName, $prefix )
{
$element = $types->getElement( $localName, $prefix );
if ( ! $element || ! isset( $element['types'] ) || ! count( $element['types'] ) ) return XBRL_Equality::$EQUALITY_TYPE_STRING;
return XBRL_Equality::xEqualComparisonType( array( 'type' => $element['types'][0] ), $types);
} | php | private static function xequalElementType( $types, $localName, $prefix )
{
$element = $types->getElement( $localName, $prefix );
if ( ! $element || ! isset( $element['types'] ) || ! count( $element['types'] ) ) return XBRL_Equality::$EQUALITY_TYPE_STRING;
return XBRL_Equality::xEqualComparisonType( array( 'type' => $element['types'][0] ), $types);
} | [
"private",
"static",
"function",
"xequalElementType",
"(",
"$",
"types",
",",
"$",
"localName",
",",
"$",
"prefix",
")",
"{",
"$",
"element",
"=",
"$",
"types",
"->",
"getElement",
"(",
"$",
"localName",
",",
"$",
"prefix",
")",
";",
"if",
"(",
"!",
... | Get the xequal comparison type an element
@param XBRL_Types $types
@param string $localName
@param string|null $prefix
@return number | [
"Get",
"the",
"xequal",
"comparison",
"type",
"an",
"element"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Equality.php#L767-L773 | train |
bseddon/XBRL | XBRL-Equality.php | XBRL_Equality.compare_arrays_ordinal | public static function compare_arrays_ordinal( $array1, $array2 )
{
if ( count( $array1 ) != count( $array2 ) ) return false;
if ( ! count( $array1 ) ) return true;
$types = XBRL_Types::getInstance();
for( $i = 0; $i < count( $array1 ); $i++ )
{
$key1 = key( $array1 );
$key2 = key( $array2 );
if ( $key1 != $key2 ) return false;
$value1 = current( $array1 );
$value2 = current( $array2 );
next( $array1 );
next( $array2 );
if ( $key1 == 'id' )
{
$pattern = "/^" . SchemaTypes::$ncName . "$/u";
if ( ! preg_match( $pattern, $value1, $matches ) )
{
$this->log()->taxonomy_validation( "context", "id attribute is not a valid NCName", array( 'id' => $value1 ) );
}
if ( ! preg_match( $pattern, $value2, $matches ) )
{
$this->log()->taxonomy_validation( "context", "id attribute is not a valid NCName", array( 'id' => $value2 ) );
}
}
if ( is_array( $value1 ) )
{
if ( ! is_array( $value2 ) ) return false;
// These arrays will represent elements so compare the contents by name
if ( ! XBRL_Equality::compare_arrays( $value1, $value2 ) )
{
return false;
}
}
else if ( in_array( $key1, array( 'id', 'name', 'prefix', 'type' ) ) )
{
if ( $value1 != $value2 )
{
return false;
}
}
else
{
$value1Type = XBRL_Equality::xEqualComparisonType( $value1, $types );
$value2Type = XBRL_Equality::xEqualComparisonType( $value2, $types );
if ( ! XBRL_Equality::xequal( $value1, $value2, $value1Type, $value2Type, $types ) )
{
return false;
}
}
}
return true;
} | php | public static function compare_arrays_ordinal( $array1, $array2 )
{
if ( count( $array1 ) != count( $array2 ) ) return false;
if ( ! count( $array1 ) ) return true;
$types = XBRL_Types::getInstance();
for( $i = 0; $i < count( $array1 ); $i++ )
{
$key1 = key( $array1 );
$key2 = key( $array2 );
if ( $key1 != $key2 ) return false;
$value1 = current( $array1 );
$value2 = current( $array2 );
next( $array1 );
next( $array2 );
if ( $key1 == 'id' )
{
$pattern = "/^" . SchemaTypes::$ncName . "$/u";
if ( ! preg_match( $pattern, $value1, $matches ) )
{
$this->log()->taxonomy_validation( "context", "id attribute is not a valid NCName", array( 'id' => $value1 ) );
}
if ( ! preg_match( $pattern, $value2, $matches ) )
{
$this->log()->taxonomy_validation( "context", "id attribute is not a valid NCName", array( 'id' => $value2 ) );
}
}
if ( is_array( $value1 ) )
{
if ( ! is_array( $value2 ) ) return false;
// These arrays will represent elements so compare the contents by name
if ( ! XBRL_Equality::compare_arrays( $value1, $value2 ) )
{
return false;
}
}
else if ( in_array( $key1, array( 'id', 'name', 'prefix', 'type' ) ) )
{
if ( $value1 != $value2 )
{
return false;
}
}
else
{
$value1Type = XBRL_Equality::xEqualComparisonType( $value1, $types );
$value2Type = XBRL_Equality::xEqualComparisonType( $value2, $types );
if ( ! XBRL_Equality::xequal( $value1, $value2, $value1Type, $value2Type, $types ) )
{
return false;
}
}
}
return true;
} | [
"public",
"static",
"function",
"compare_arrays_ordinal",
"(",
"$",
"array1",
",",
"$",
"array2",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"array1",
")",
"!=",
"count",
"(",
"$",
"array2",
")",
")",
"return",
"false",
";",
"if",
"(",
"!",
"count",
"("... | Compare arrays using the position of the elements
@param array $array1
@param array $array2
@return bool | [
"Compare",
"arrays",
"using",
"the",
"position",
"of",
"the",
"elements"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Equality.php#L781-L843 | train |
bseddon/XBRL | XBRL-Equality.php | XBRL_Equality.hasElement | private static function hasElement( $a, $b, $elementName )
{
return
( isset( $a[ $elementName ] ) && isset( $b[ $elementName ] ) ) ||
( ! isset( $a[ $elementName ] ) && ! isset( $b[ $elementName ] ) );
} | php | private static function hasElement( $a, $b, $elementName )
{
return
( isset( $a[ $elementName ] ) && isset( $b[ $elementName ] ) ) ||
( ! isset( $a[ $elementName ] ) && ! isset( $b[ $elementName ] ) );
} | [
"private",
"static",
"function",
"hasElement",
"(",
"$",
"a",
",",
"$",
"b",
",",
"$",
"elementName",
")",
"{",
"return",
"(",
"isset",
"(",
"$",
"a",
"[",
"$",
"elementName",
"]",
")",
"&&",
"isset",
"(",
"$",
"b",
"[",
"$",
"elementName",
"]",
... | Test to make sure an element exists in both arrays
@param array $a An array holding content with element names to be matched
@param array $b An array holding content with element names to be matched
@param bool $elementName
@return bool Returns true if both or neither array contains the element name | [
"Test",
"to",
"make",
"sure",
"an",
"element",
"exists",
"in",
"both",
"arrays"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Equality.php#L891-L896 | train |
bseddon/XBRL | Formulas/Resources/Formulas/Aspects/EntityIdentifier.php | EntityIdentifier.getValue | public function getValue( $variableSet, $evaluationResult, $log )
{
// Should already have been validated that if there is no source, there MUST be a complete entity identifier aspect is defined.
if ( $this->source )
{
$sourceFact = $variableSet->getSourceFact( $this->source, $evaluationResult, ASPECT_ENTITY_IDENTIFIER, $log );
if ( is_null( $sourceFact ) )
{
$source = is_array( $this->source ) ? "{$this->source['originalPrefix']}:{$this->source['name']}" : $this->source;
$log->formula_validation( "Formula", "Invalid or missing source fact for entity identifier",
array(
'source' => $source,
'error' => 'xbrlfe:undefinedSAV'
)
);
}
$contextRef = FactValues::getContextRef( $sourceFact );
if ( ! $contextRef ) return null;
$context = $variableSet->xbrlInstance->getContext( $contextRef );
$identifier = isset( $context['entity']['identifier'] )
? $context['entity']['identifier']
: array();
}
if ( $this->scheme )
{
$result = $this->evaluateXPath( $variableSet, "{$this->scheme} cast as xs:string", $evaluationResult['vars'] );
$identifier['scheme'] = is_object( $result ) ? $result->getValue() : $result;
}
if ( $this->value )
{
$result = $this->evaluateXPath( $variableSet, "({$this->value}) cast as xs:string", $evaluationResult['vars'] );
$identifier['value'] = is_object( $result ) ? $result->getValue() : $result;
}
return $identifier;
} | php | public function getValue( $variableSet, $evaluationResult, $log )
{
// Should already have been validated that if there is no source, there MUST be a complete entity identifier aspect is defined.
if ( $this->source )
{
$sourceFact = $variableSet->getSourceFact( $this->source, $evaluationResult, ASPECT_ENTITY_IDENTIFIER, $log );
if ( is_null( $sourceFact ) )
{
$source = is_array( $this->source ) ? "{$this->source['originalPrefix']}:{$this->source['name']}" : $this->source;
$log->formula_validation( "Formula", "Invalid or missing source fact for entity identifier",
array(
'source' => $source,
'error' => 'xbrlfe:undefinedSAV'
)
);
}
$contextRef = FactValues::getContextRef( $sourceFact );
if ( ! $contextRef ) return null;
$context = $variableSet->xbrlInstance->getContext( $contextRef );
$identifier = isset( $context['entity']['identifier'] )
? $context['entity']['identifier']
: array();
}
if ( $this->scheme )
{
$result = $this->evaluateXPath( $variableSet, "{$this->scheme} cast as xs:string", $evaluationResult['vars'] );
$identifier['scheme'] = is_object( $result ) ? $result->getValue() : $result;
}
if ( $this->value )
{
$result = $this->evaluateXPath( $variableSet, "({$this->value}) cast as xs:string", $evaluationResult['vars'] );
$identifier['value'] = is_object( $result ) ? $result->getValue() : $result;
}
return $identifier;
} | [
"public",
"function",
"getValue",
"(",
"$",
"variableSet",
",",
"$",
"evaluationResult",
",",
"$",
"log",
")",
"{",
"// Should already have been validated that if there is no source, there MUST be a complete entity identifier aspect is defined.\r",
"if",
"(",
"$",
"this",
"->",... | Returns an aspect value
@param Formula $variableSet
@param array $evaluationResult
@param \XBRL_Log $log
@return array | [
"Returns",
"an",
"aspect",
"value"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/Formulas/Resources/Formulas/Aspects/EntityIdentifier.php#L115-L153 | train |
bseddon/XBRL | XBRL-Package.php | XBRL_Package.getPackage | public static function getPackage( $taxonomyPackage, $additionalPackageClasses = array() )
{
if ( ! is_array( $additionalPackageClasses ) )
{
$additionalPackageClasses = array();
}
$packageClassesFile = __DIR__ . '/TaxonomyPackageTypes.json';
$packageClasses = null;
if ( file_exists( __DIR__ . '/TaxonomyPackageTypes.json' ) )
{
// echo file_get_contents( __DIR__ . '/TaxonomyPackageTypes.json' );
$json = json_decode( file_get_contents( __DIR__ . '/TaxonomyPackageTypes.json' ), true );
if ( $json && isset( $json['classNames'] ) )
{
$packageClasses = $json['classNames'];
}
else
{
echo "Unable to load the package classes JSON file" . XBRL::json_last_error_msg() , "\n";
}
}
if ( ! $packageClasses )
{
$packageClasses = array( 'XBRL_TaxonomyPackage', 'XBRL_SEC_JSON_Package', 'XBRL_SEC_XML_Package', 'XBRL_SimplePackage' );
}
// Any additional package classes should be evaluated first.
// Additional classes should make sure there is validation so they are not used when they are really not suitable
$packageClasses = $additionalPackageClasses + $packageClasses;
foreach ( $packageClasses as $packageClassName )
{
/** @var XBRL_Package $package */
$package = XBRL_Package::fromFile( $taxonomyPackage, $packageClassName );
if ( ! $package->isPackage() ) continue;
// Load the XBRL class
$className = $package->getXBRLClassname();
class_exists( $className, true );
return $package;
}
if ( ! $found )
{
$zip = basename( $taxonomyPackage );
throw new Exception( "The contents of file '$zip' do not match any of the supported taxonomy package formats" );
}
} | php | public static function getPackage( $taxonomyPackage, $additionalPackageClasses = array() )
{
if ( ! is_array( $additionalPackageClasses ) )
{
$additionalPackageClasses = array();
}
$packageClassesFile = __DIR__ . '/TaxonomyPackageTypes.json';
$packageClasses = null;
if ( file_exists( __DIR__ . '/TaxonomyPackageTypes.json' ) )
{
// echo file_get_contents( __DIR__ . '/TaxonomyPackageTypes.json' );
$json = json_decode( file_get_contents( __DIR__ . '/TaxonomyPackageTypes.json' ), true );
if ( $json && isset( $json['classNames'] ) )
{
$packageClasses = $json['classNames'];
}
else
{
echo "Unable to load the package classes JSON file" . XBRL::json_last_error_msg() , "\n";
}
}
if ( ! $packageClasses )
{
$packageClasses = array( 'XBRL_TaxonomyPackage', 'XBRL_SEC_JSON_Package', 'XBRL_SEC_XML_Package', 'XBRL_SimplePackage' );
}
// Any additional package classes should be evaluated first.
// Additional classes should make sure there is validation so they are not used when they are really not suitable
$packageClasses = $additionalPackageClasses + $packageClasses;
foreach ( $packageClasses as $packageClassName )
{
/** @var XBRL_Package $package */
$package = XBRL_Package::fromFile( $taxonomyPackage, $packageClassName );
if ( ! $package->isPackage() ) continue;
// Load the XBRL class
$className = $package->getXBRLClassname();
class_exists( $className, true );
return $package;
}
if ( ! $found )
{
$zip = basename( $taxonomyPackage );
throw new Exception( "The contents of file '$zip' do not match any of the supported taxonomy package formats" );
}
} | [
"public",
"static",
"function",
"getPackage",
"(",
"$",
"taxonomyPackage",
",",
"$",
"additionalPackageClasses",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"additionalPackageClasses",
")",
")",
"{",
"$",
"additionalPackageClasses",
... | Factory to create a package class instance
@param string $taxonomyPackage
@param array $additionalPackageClasses (optional) A list of other packaging classes that could be valid
@throws Exception
@return XBRL_Package | [
"Factory",
"to",
"create",
"a",
"package",
"class",
"instance"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Package.php#L50-L99 | train |
bseddon/XBRL | XBRL-Package.php | XBRL_Package.fromFile | public static function fromFile( string $filename, $className )
{
$zipArchive = new ZipArchive();
try
{
if ( $zipArchive->open( $filename ) !== true )
{
$zipArchive = false;
throw new Exception("An attempt has been made to open an invalid zip file");
}
return self::fromZip( $zipArchive, $className );
}
catch ( Exception $ex )
{
if ( $zipArchive ) $zipArchive->close();
throw XBRL_TaxonomyPackageException::withError( "tpe:invalidArchiveFormat", $ex->getMessage() );
}
return false;
} | php | public static function fromFile( string $filename, $className )
{
$zipArchive = new ZipArchive();
try
{
if ( $zipArchive->open( $filename ) !== true )
{
$zipArchive = false;
throw new Exception("An attempt has been made to open an invalid zip file");
}
return self::fromZip( $zipArchive, $className );
}
catch ( Exception $ex )
{
if ( $zipArchive ) $zipArchive->close();
throw XBRL_TaxonomyPackageException::withError( "tpe:invalidArchiveFormat", $ex->getMessage() );
}
return false;
} | [
"public",
"static",
"function",
"fromFile",
"(",
"string",
"$",
"filename",
",",
"$",
"className",
")",
"{",
"$",
"zipArchive",
"=",
"new",
"ZipArchive",
"(",
")",
";",
"try",
"{",
"if",
"(",
"$",
"zipArchive",
"->",
"open",
"(",
"$",
"filename",
")",
... | Open a package from a file
@param string $filename
@param string $className
return XBRL_Package
@throws Exception | [
"Open",
"a",
"package",
"from",
"a",
"file"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Package.php#L108-L128 | train |
bseddon/XBRL | XBRL-Package.php | XBRL_Package.compile | public function compile( $output_basename = null, $compiledPath = null )
{
if ( $this->isExtensionTaxonomy() )
{
return XBRL::compileExtensionXSD( $this->schemaFile, $this->getXBRLClassname(), $this->schemaNamespace, $output_basename, $compiledPath );
}
else
{
return XBRL::compile(
$this->schemaFile,
$this->schemaNamespace,
$compiledPath . ( is_null( $output_basename ) ? $this->getSchemaFileBasename() : $output_basename )
);
}
} | php | public function compile( $output_basename = null, $compiledPath = null )
{
if ( $this->isExtensionTaxonomy() )
{
return XBRL::compileExtensionXSD( $this->schemaFile, $this->getXBRLClassname(), $this->schemaNamespace, $output_basename, $compiledPath );
}
else
{
return XBRL::compile(
$this->schemaFile,
$this->schemaNamespace,
$compiledPath . ( is_null( $output_basename ) ? $this->getSchemaFileBasename() : $output_basename )
);
}
} | [
"public",
"function",
"compile",
"(",
"$",
"output_basename",
"=",
"null",
",",
"$",
"compiledPath",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isExtensionTaxonomy",
"(",
")",
")",
"{",
"return",
"XBRL",
"::",
"compileExtensionXSD",
"(",
"$",
... | Compile a taxonmy
@param string $output_basename Name of the compiled taxonomy to create
@param string $compiledPath (optional) Path to the compiled taxonomies folder
@return bool
@throws Exception | [
"Compile",
"a",
"taxonmy"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Package.php#L247-L261 | train |
bseddon/XBRL | XBRL-Package.php | XBRL_Package.isCompiled | public function isCompiled( $compiledDir, $basename = null )
{
if ( is_null( $basename ) )
{
$basename = $this->getSchemaFileBasename();
}
return XBRL::isCompiled( $compiledDir, $basename );
} | php | public function isCompiled( $compiledDir, $basename = null )
{
if ( is_null( $basename ) )
{
$basename = $this->getSchemaFileBasename();
}
return XBRL::isCompiled( $compiledDir, $basename );
} | [
"public",
"function",
"isCompiled",
"(",
"$",
"compiledDir",
",",
"$",
"basename",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"basename",
")",
")",
"{",
"$",
"basename",
"=",
"$",
"this",
"->",
"getSchemaFileBasename",
"(",
")",
";",
"}",
... | Returns true if the taxonomy in the package is compiled
@param string $compiledDir Path to the compiled taxonomies folder
@param string $basename Specifies an explicit basename. Otherwise the basename of the schema name is used.
@return bool | [
"Returns",
"true",
"if",
"the",
"taxonomy",
"in",
"the",
"package",
"is",
"compiled"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Package.php#L275-L283 | train |
bseddon/XBRL | XBRL-Package.php | XBRL_Package.isExtensionTaxonomy | public function isExtensionTaxonomy()
{
if ( is_null( $this->isExtensionTaxonomy ) )
{
$this->isExtensionTaxonomy = $this->getIsExtensionTaxonomy();
}
return $this->isExtensionTaxonomy;
} | php | public function isExtensionTaxonomy()
{
if ( is_null( $this->isExtensionTaxonomy ) )
{
$this->isExtensionTaxonomy = $this->getIsExtensionTaxonomy();
}
return $this->isExtensionTaxonomy;
} | [
"public",
"function",
"isExtensionTaxonomy",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"isExtensionTaxonomy",
")",
")",
"{",
"$",
"this",
"->",
"isExtensionTaxonomy",
"=",
"$",
"this",
"->",
"getIsExtensionTaxonomy",
"(",
")",
";",
"}",
... | Returns true if the package contains an extension taxonomy
@return bool
@final | [
"Returns",
"true",
"if",
"the",
"package",
"contains",
"an",
"extension",
"taxonomy"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Package.php#L296-L303 | train |
bseddon/XBRL | XBRL-Package.php | XBRL_Package.getIsExtensionTaxonomy | protected function getIsExtensionTaxonomy()
{
$this->determineSchemaFile();
// If the schema in the package imports one of the schemas with an entry point namespace then an extension compilation should be used
$xml = $this->getFileAsXML( $this->getActualUri( $this->schemaFile ) );
$xml->registerXPathNamespace( SCHEMA_PREFIX, SCHEMA_NAMESPACE );
foreach ( $xml->xpath("/xs:schema/xs:import") as $tag => /** @var SimpleXMLElement $element */ $element )
{
$attributes = $element->attributes();
if ( ! isset( $attributes['namespace'] ) ) continue;
// echo "{$attributes['namespace']}\n";
$nameOfXBRLClass = $this->getXBRLClassname();
if ( ( $className = $nameOfXBRLClass::class_from_namespace( (string)$attributes['namespace'] ) ) == "XBRL" ) continue;
return true;
}
return false;
} | php | protected function getIsExtensionTaxonomy()
{
$this->determineSchemaFile();
// If the schema in the package imports one of the schemas with an entry point namespace then an extension compilation should be used
$xml = $this->getFileAsXML( $this->getActualUri( $this->schemaFile ) );
$xml->registerXPathNamespace( SCHEMA_PREFIX, SCHEMA_NAMESPACE );
foreach ( $xml->xpath("/xs:schema/xs:import") as $tag => /** @var SimpleXMLElement $element */ $element )
{
$attributes = $element->attributes();
if ( ! isset( $attributes['namespace'] ) ) continue;
// echo "{$attributes['namespace']}\n";
$nameOfXBRLClass = $this->getXBRLClassname();
if ( ( $className = $nameOfXBRLClass::class_from_namespace( (string)$attributes['namespace'] ) ) == "XBRL" ) continue;
return true;
}
return false;
} | [
"protected",
"function",
"getIsExtensionTaxonomy",
"(",
")",
"{",
"$",
"this",
"->",
"determineSchemaFile",
"(",
")",
";",
"// If the schema in the package imports one of the schemas with an entry point namespace then an extension compilation should be used\r",
"$",
"xml",
"=",
"$"... | Can be implemented by concrete classes to return true if the taxonomy is an extension taxonomy
This default implementation looks at the XBRL class name advertised by the class to determine
if the schema file contains one of the entry points of the XBRL class.
@return bool
@abstract | [
"Can",
"be",
"implemented",
"by",
"concrete",
"classes",
"to",
"return",
"true",
"if",
"the",
"taxonomy",
"is",
"an",
"extension",
"taxonomy",
"This",
"default",
"implementation",
"looks",
"at",
"the",
"XBRL",
"class",
"name",
"advertised",
"by",
"the",
"class... | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Package.php#L322-L341 | train |
bseddon/XBRL | XBRL-Package.php | XBRL_Package.getInstanceDocumentAsMemoryFile | public function getInstanceDocumentAsMemoryFile()
{
// If this returns null there is no instance document
$xbrl = $this->getInstanceDocument( false );
if ( ! $xbrl ) return false;
$instanceFilename = "mem://{$this->instanceDocument}";
if ( ! class_exists("MemoryStream", true ) )
{
/**
* Load the dictionary class
*/
$utiltiesPath = isset( $_ENV['UTILITY_LIBRARY_PATH'] )
? $_ENV['UTILITY_LIBRARY_PATH']
: ( defined( 'UTILITY_LIBRARY_PATH' ) ? UTILITY_LIBRARY_PATH : __DIR__ . "/../utilities" );
require_once "$utiltiesPath/MemoryStream.php";
}
$f = fopen( $instanceFilename, "w+" );
fwrite( $f, $xbrl );
fclose( $f );
return $instanceFilename;
} | php | public function getInstanceDocumentAsMemoryFile()
{
// If this returns null there is no instance document
$xbrl = $this->getInstanceDocument( false );
if ( ! $xbrl ) return false;
$instanceFilename = "mem://{$this->instanceDocument}";
if ( ! class_exists("MemoryStream", true ) )
{
/**
* Load the dictionary class
*/
$utiltiesPath = isset( $_ENV['UTILITY_LIBRARY_PATH'] )
? $_ENV['UTILITY_LIBRARY_PATH']
: ( defined( 'UTILITY_LIBRARY_PATH' ) ? UTILITY_LIBRARY_PATH : __DIR__ . "/../utilities" );
require_once "$utiltiesPath/MemoryStream.php";
}
$f = fopen( $instanceFilename, "w+" );
fwrite( $f, $xbrl );
fclose( $f );
return $instanceFilename;
} | [
"public",
"function",
"getInstanceDocumentAsMemoryFile",
"(",
")",
"{",
"// If this returns null there is no instance document\r",
"$",
"xbrl",
"=",
"$",
"this",
"->",
"getInstanceDocument",
"(",
"false",
")",
";",
"if",
"(",
"!",
"$",
"xbrl",
")",
"return",
"false"... | Retruns the instance document contents as named memory stream file
@return boolean|string | [
"Retruns",
"the",
"instance",
"document",
"contents",
"as",
"named",
"memory",
"stream",
"file"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Package.php#L516-L540 | train |
bseddon/XBRL | XBRL-Package.php | XBRL_Package.getInstanceDocument | public function getInstanceDocument( $asSimpleXML = true )
{
if ( ! $this->schemaFile || ! $this->schemaNamespace )
{
echo "The saveTaxonomy function must be called before using this function";
return false;
}
if ( $this->instanceDocument )
{
$xml = $asSimpleXML
? $this->getFileAsXML( $this->instanceDocument )
: $this->getFile( $this->instanceDocument );
return $xml;
}
$xml = null;
$this->traverseContents( function( $path, $name, $type ) use( &$xml )
{
if ( $type == PATHINFO_DIRNAME ) return true;
$extension = pathinfo( $name, PATHINFO_EXTENSION );
if ( ! in_array( $extension, array( 'xml', 'xbrl' ) ) ) return true;
$path = $path ? "$path$name" : $name;
$xml = $this->getFileAsXML( $path );
if ( ! $xml instanceof SimpleXMLElement ) return true;
if ( $xml->getName() != "xbrl" )
{
$xml = null;
return true;
}
$this->instanceDocument = $path;
return false;
} );
if ( ! $xml instanceof SimpleXMLElement ) return null;
return $asSimpleXML
? $xml
: $this->getFile( $this->instanceDocument );
} | php | public function getInstanceDocument( $asSimpleXML = true )
{
if ( ! $this->schemaFile || ! $this->schemaNamespace )
{
echo "The saveTaxonomy function must be called before using this function";
return false;
}
if ( $this->instanceDocument )
{
$xml = $asSimpleXML
? $this->getFileAsXML( $this->instanceDocument )
: $this->getFile( $this->instanceDocument );
return $xml;
}
$xml = null;
$this->traverseContents( function( $path, $name, $type ) use( &$xml )
{
if ( $type == PATHINFO_DIRNAME ) return true;
$extension = pathinfo( $name, PATHINFO_EXTENSION );
if ( ! in_array( $extension, array( 'xml', 'xbrl' ) ) ) return true;
$path = $path ? "$path$name" : $name;
$xml = $this->getFileAsXML( $path );
if ( ! $xml instanceof SimpleXMLElement ) return true;
if ( $xml->getName() != "xbrl" )
{
$xml = null;
return true;
}
$this->instanceDocument = $path;
return false;
} );
if ( ! $xml instanceof SimpleXMLElement ) return null;
return $asSimpleXML
? $xml
: $this->getFile( $this->instanceDocument );
} | [
"public",
"function",
"getInstanceDocument",
"(",
"$",
"asSimpleXML",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"schemaFile",
"||",
"!",
"$",
"this",
"->",
"schemaNamespace",
")",
"{",
"echo",
"\"The saveTaxonomy function must be called before usin... | Get the instance document xml
@param bool $asSimpleXML
@return SimpleXMLElement|string | [
"Get",
"the",
"instance",
"document",
"xml"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Package.php#L547-L589 | train |
bseddon/XBRL | XBRL-Package.php | XBRL_Package.processSchemaDocument | protected function processSchemaDocument( $context, $content, $throwException = true )
{
if ( ! isXml( $content, $throwException ) ) return false;
if ( is_null( $this->schemaNamespace ) )
{
$this->schemaNamespace = $this->getTargetNamespace( $this->schemaFile, $content, $throwException );
if ( ! $this->schemaNamespace )
{
$msg = "Unable to find the taxonomy namespace";
$this->errors[] = $msg;
if ( $throwException )
{
throw new \Exception( $msg );
}
return false;
}
}
$part = parse_url( $this->schemaFile, PHP_URL_SCHEME );
$prefix = empty( $part ) ? $this->schemaNamespace . "/" : "";
$schemaFile = "$prefix{$this->schemaFile}";
if ( $context->findCachedFile( "$schemaFile" ) )
{
$msg = "The taxonomy already exists in the cache";
$this->errors[] = $msg;
if ( $throwException )
{
throw new \Exception( $msg );
}
return false;
}
if ( ! $context->saveCacheFile( "$schemaFile", $content ) )
{
$msg = "Unable to save the schema file ('$schemaFile')";
$this->errors[] = $msg;
if ( $throwException )
{
throw new \Exception( $msg );
}
return false;
}
return $this->schemaNamespace;
} | php | protected function processSchemaDocument( $context, $content, $throwException = true )
{
if ( ! isXml( $content, $throwException ) ) return false;
if ( is_null( $this->schemaNamespace ) )
{
$this->schemaNamespace = $this->getTargetNamespace( $this->schemaFile, $content, $throwException );
if ( ! $this->schemaNamespace )
{
$msg = "Unable to find the taxonomy namespace";
$this->errors[] = $msg;
if ( $throwException )
{
throw new \Exception( $msg );
}
return false;
}
}
$part = parse_url( $this->schemaFile, PHP_URL_SCHEME );
$prefix = empty( $part ) ? $this->schemaNamespace . "/" : "";
$schemaFile = "$prefix{$this->schemaFile}";
if ( $context->findCachedFile( "$schemaFile" ) )
{
$msg = "The taxonomy already exists in the cache";
$this->errors[] = $msg;
if ( $throwException )
{
throw new \Exception( $msg );
}
return false;
}
if ( ! $context->saveCacheFile( "$schemaFile", $content ) )
{
$msg = "Unable to save the schema file ('$schemaFile')";
$this->errors[] = $msg;
if ( $throwException )
{
throw new \Exception( $msg );
}
return false;
}
return $this->schemaNamespace;
} | [
"protected",
"function",
"processSchemaDocument",
"(",
"$",
"context",
",",
"$",
"content",
",",
"$",
"throwException",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"isXml",
"(",
"$",
"content",
",",
"$",
"throwException",
")",
")",
"return",
"false",
";",
"if... | Processes the schema document in a consistent way
@param \XBRL_Global $context A reference to the global context
@param bytes $content Expected to be an XML schema
@param bool $throwException True if an exception should be thrown on error or false is returned otherwise
@return bool
@throws \Exception | [
"Processes",
"the",
"schema",
"document",
"in",
"a",
"consistent",
"way"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Package.php#L651-L703 | train |
bseddon/XBRL | XBRL-Package.php | XBRL_Package.setUrlMap | protected function setUrlMap( $schemaNamespace = null, $schemaFile = null )
{
if ( $schemaNamespace && ! $schemaFile || $schemaFile && ! $schemaNamespace )
{
throw new Exception('setUrlMap: If a schema file or schema namespace is provided to the setUrlMapo function then both MUST be provided.');
}
if ( ! $schemaFile )
{
$schemaFile = $this->schemaFile;
}
if ( ! $schemaNamespace )
{
$schemaNamespace = $this->schemaNamespace;
}
if ( ! $schemaNamespace ) return;
global $mapUrl; // This is a function assigned below. Effectively a change of url maps is created.
$previousMap = $mapUrl;
// $schemaFile = $this->schemaFile;
$mapUrl = function( $url ) use( &$previousMap, $schemaFile )
{
if ( $url == basename( $schemaFile ) )
{
$url = $schemaFile;
}
else if ( $previousMap )
{
$url = $previousMap( $url );
}
return $url;
};
} | php | protected function setUrlMap( $schemaNamespace = null, $schemaFile = null )
{
if ( $schemaNamespace && ! $schemaFile || $schemaFile && ! $schemaNamespace )
{
throw new Exception('setUrlMap: If a schema file or schema namespace is provided to the setUrlMapo function then both MUST be provided.');
}
if ( ! $schemaFile )
{
$schemaFile = $this->schemaFile;
}
if ( ! $schemaNamespace )
{
$schemaNamespace = $this->schemaNamespace;
}
if ( ! $schemaNamespace ) return;
global $mapUrl; // This is a function assigned below. Effectively a change of url maps is created.
$previousMap = $mapUrl;
// $schemaFile = $this->schemaFile;
$mapUrl = function( $url ) use( &$previousMap, $schemaFile )
{
if ( $url == basename( $schemaFile ) )
{
$url = $schemaFile;
}
else if ( $previousMap )
{
$url = $previousMap( $url );
}
return $url;
};
} | [
"protected",
"function",
"setUrlMap",
"(",
"$",
"schemaNamespace",
"=",
"null",
",",
"$",
"schemaFile",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"schemaNamespace",
"&&",
"!",
"$",
"schemaFile",
"||",
"$",
"schemaFile",
"&&",
"!",
"$",
"schemaNamespace",
")",... | Implements a Url map that allows a simple xsd name to map to a path that can be found in the cache
@param string $schemaNamespace
@param string $schemaFile
@throws Exception | [
"Implements",
"a",
"Url",
"map",
"that",
"allows",
"a",
"simple",
"xsd",
"name",
"to",
"map",
"to",
"a",
"path",
"that",
"can",
"be",
"found",
"in",
"the",
"cache"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Package.php#L711-L747 | train |
bseddon/XBRL | XBRL-Package.php | XBRL_Package.loadTaxonomy | public function loadTaxonomy( $compiledPath = null )
{
if ( $this->isExtensionTaxonomy() )
{
return XBRL::loadExtensionXSD( $this->schemaFile, $this->getXBRLClassname(), $this->schemaNamespace, $compiledPath );
}
else
{
if ( $this->isCompiled( $compiledPath, $this->getSchemaFileBasename() ) )
{
return XBRL::load_taxonomy(
"$compiledPath/" . $this->getSchemaFileBasename(".json"),
false
);
}
return XBRL::withTaxonomy( $this->schemaFile );
}
} | php | public function loadTaxonomy( $compiledPath = null )
{
if ( $this->isExtensionTaxonomy() )
{
return XBRL::loadExtensionXSD( $this->schemaFile, $this->getXBRLClassname(), $this->schemaNamespace, $compiledPath );
}
else
{
if ( $this->isCompiled( $compiledPath, $this->getSchemaFileBasename() ) )
{
return XBRL::load_taxonomy(
"$compiledPath/" . $this->getSchemaFileBasename(".json"),
false
);
}
return XBRL::withTaxonomy( $this->schemaFile );
}
} | [
"public",
"function",
"loadTaxonomy",
"(",
"$",
"compiledPath",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isExtensionTaxonomy",
"(",
")",
")",
"{",
"return",
"XBRL",
"::",
"loadExtensionXSD",
"(",
"$",
"this",
"->",
"schemaFile",
",",
"$",
"t... | Load the taxonomy associated with this package
@param string $compiledPath
@return boolean|XBRL | [
"Load",
"the",
"taxonomy",
"associated",
"with",
"this",
"package"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Package.php#L764-L782 | train |
bseddon/XBRL | examples/Case Study DK/Observer.php | Observer.notify | public function notify( $event )
{
if ( ! isset( $event['section'] ) || ! isset( $event['source'] ) ) return;
$source = $event['section'];
$source = array( 'message' => $event['message'], 'details' => $event['source'] );
$this->addSection( $event['section'], $source );
} | php | public function notify( $event )
{
if ( ! isset( $event['section'] ) || ! isset( $event['source'] ) ) return;
$source = $event['section'];
$source = array( 'message' => $event['message'], 'details' => $event['source'] );
$this->addSection( $event['section'], $source );
} | [
"public",
"function",
"notify",
"(",
"$",
"event",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"event",
"[",
"'section'",
"]",
")",
"||",
"!",
"isset",
"(",
"$",
"event",
"[",
"'source'",
"]",
")",
")",
"return",
";",
"$",
"source",
"=",
"$",
... | Called by the log instance to pass log information
@param array $event | [
"Called",
"by",
"the",
"log",
"instance",
"to",
"pass",
"log",
"information"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/examples/Case Study DK/Observer.php#L47-L54 | train |
bseddon/XBRL | Formulas/GeneralVariableBinding.php | GeneralVariableBinding.partitionFacts | public function partitionFacts( $variableSet )
{
if ( ! $this->var->bindAsSequence ) return;
$groups = array();
// This is a bit belt-and-braces but just to be sure
if ( $this->facts instanceof XPath2NodeIterator )
{
$groups[] = $this->facts->CloneInstance();
}
else if ( is_array( $this->facts ) )
{
$groups[] = DocumentOrderNodeIterator::fromItemset( $this->facts, true );
}
else
{
$groups[] = DocumentOrderNodeIterator::fromItemset( array( $this->facts ) );
}
$this->facts = DocumentOrderNodeIterator::fromItemset( $groups );
} | php | public function partitionFacts( $variableSet )
{
if ( ! $this->var->bindAsSequence ) return;
$groups = array();
// This is a bit belt-and-braces but just to be sure
if ( $this->facts instanceof XPath2NodeIterator )
{
$groups[] = $this->facts->CloneInstance();
}
else if ( is_array( $this->facts ) )
{
$groups[] = DocumentOrderNodeIterator::fromItemset( $this->facts, true );
}
else
{
$groups[] = DocumentOrderNodeIterator::fromItemset( array( $this->facts ) );
}
$this->facts = DocumentOrderNodeIterator::fromItemset( $groups );
} | [
"public",
"function",
"partitionFacts",
"(",
"$",
"variableSet",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"var",
"->",
"bindAsSequence",
")",
"return",
";",
"$",
"groups",
"=",
"array",
"(",
")",
";",
"// This is a bit belt-and-braces but just to be sure\r",... | If the bound variable specifies bind as a sequence then put the facts into a container
@param Formula $variableSet
@return void | [
"If",
"the",
"bound",
"variable",
"specifies",
"bind",
"as",
"a",
"sequence",
"then",
"put",
"the",
"facts",
"into",
"a",
"container"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/Formulas/GeneralVariableBinding.php#L45-L66 | train |
bseddon/XBRL | XBRL-QName.php | QNamex.equals | public function equals( $other )
{
try
{
return $this->qnameValueHash == $other->qnameValueHash ||
( $this->localName == $other->localName && $this->namespaceURI == $other->namespaceURI );
}
catch( \Exception $ex )
{
return false;
}
} | php | public function equals( $other )
{
try
{
return $this->qnameValueHash == $other->qnameValueHash ||
( $this->localName == $other->localName && $this->namespaceURI == $other->namespaceURI );
}
catch( \Exception $ex )
{
return false;
}
} | [
"public",
"function",
"equals",
"(",
"$",
"other",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"qnameValueHash",
"==",
"$",
"other",
"->",
"qnameValueHash",
"||",
"(",
"$",
"this",
"->",
"localName",
"==",
"$",
"other",
"->",
"localName",
"&&",
... | Test whether one QName equals another
@param QName $other
@return boolean | [
"Test",
"whether",
"one",
"QName",
"equals",
"another"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-QName.php#L432-L443 | train |
bseddon/XBRL | XBRL-QName.php | QNamex.lessThan | public function lessThan( $other )
{
return $this->namespaceURI == null && $other->namespaceURI ||
$this->namespaceURI && $other->namespaceURI && $this->namespaceURI < $other->namespaceURI ||
$this->namespaceURI == $other->namespaceURI && $this->localName < $other->localName;
} | php | public function lessThan( $other )
{
return $this->namespaceURI == null && $other->namespaceURI ||
$this->namespaceURI && $other->namespaceURI && $this->namespaceURI < $other->namespaceURI ||
$this->namespaceURI == $other->namespaceURI && $this->localName < $other->localName;
} | [
"public",
"function",
"lessThan",
"(",
"$",
"other",
")",
"{",
"return",
"$",
"this",
"->",
"namespaceURI",
"==",
"null",
"&&",
"$",
"other",
"->",
"namespaceURI",
"||",
"$",
"this",
"->",
"namespaceURI",
"&&",
"$",
"other",
"->",
"namespaceURI",
"&&",
"... | Test whether one QName is less than another
@param QName $other
@return boolean | [
"Test",
"whether",
"one",
"QName",
"is",
"less",
"than",
"another"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-QName.php#L451-L456 | train |
bseddon/XBRL | XBRL-QName.php | QNamex.lessThanOrEqual | public function lessThanOrEqual( $other )
{
return $this->namespaceURI == null && $other->namespaceURI ||
$this->namespaceURI && $other->namespaceURI && $this->namespaceURI < $other->namespaceURI ||
$this->namespaceURI == $other->namespaceURI && $this->localName <= $other->localName;
} | php | public function lessThanOrEqual( $other )
{
return $this->namespaceURI == null && $other->namespaceURI ||
$this->namespaceURI && $other->namespaceURI && $this->namespaceURI < $other->namespaceURI ||
$this->namespaceURI == $other->namespaceURI && $this->localName <= $other->localName;
} | [
"public",
"function",
"lessThanOrEqual",
"(",
"$",
"other",
")",
"{",
"return",
"$",
"this",
"->",
"namespaceURI",
"==",
"null",
"&&",
"$",
"other",
"->",
"namespaceURI",
"||",
"$",
"this",
"->",
"namespaceURI",
"&&",
"$",
"other",
"->",
"namespaceURI",
"&... | Test whether one QName is less than or equal to another
@param QName $other
@return boolean | [
"Test",
"whether",
"one",
"QName",
"is",
"less",
"than",
"or",
"equal",
"to",
"another"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-QName.php#L464-L469 | train |
bseddon/XBRL | XBRL-QName.php | QNamex.greaterThan | public function greaterThan( $other )
{
return $this->namespaceURI && $other->namespaceURI == null ||
$this->namespaceURI && $other->namespaceURI && $this->namespaceURI > $other->namespaceURI ||
$this->namespaceURI == $other->namespaceURI && $this->localName > $other->localName;
} | php | public function greaterThan( $other )
{
return $this->namespaceURI && $other->namespaceURI == null ||
$this->namespaceURI && $other->namespaceURI && $this->namespaceURI > $other->namespaceURI ||
$this->namespaceURI == $other->namespaceURI && $this->localName > $other->localName;
} | [
"public",
"function",
"greaterThan",
"(",
"$",
"other",
")",
"{",
"return",
"$",
"this",
"->",
"namespaceURI",
"&&",
"$",
"other",
"->",
"namespaceURI",
"==",
"null",
"||",
"$",
"this",
"->",
"namespaceURI",
"&&",
"$",
"other",
"->",
"namespaceURI",
"&&",
... | Test whether one QName is greater than another
@param QName $other
@return boolean | [
"Test",
"whether",
"one",
"QName",
"is",
"greater",
"than",
"another"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-QName.php#L477-L482 | train |
bseddon/XBRL | XBRL-QName.php | QNamex.greaterThanOrEqual | public function greaterThanOrEqual( $other )
{
return $this->namespaceURI && $other->namespaceURI == null ||
$this->namespaceURI && $other->namespaceURI && $this->namespaceURI > $other->namespaceURI ||
$this->namespaceURI == $other->namespaceURI && $this->localName >= $other->localName;
} | php | public function greaterThanOrEqual( $other )
{
return $this->namespaceURI && $other->namespaceURI == null ||
$this->namespaceURI && $other->namespaceURI && $this->namespaceURI > $other->namespaceURI ||
$this->namespaceURI == $other->namespaceURI && $this->localName >= $other->localName;
} | [
"public",
"function",
"greaterThanOrEqual",
"(",
"$",
"other",
")",
"{",
"return",
"$",
"this",
"->",
"namespaceURI",
"&&",
"$",
"other",
"->",
"namespaceURI",
"==",
"null",
"||",
"$",
"this",
"->",
"namespaceURI",
"&&",
"$",
"other",
"->",
"namespaceURI",
... | Test whether one QName is greater or equal to another
@param QName $other
@return boolean | [
"Test",
"whether",
"one",
"QName",
"is",
"greater",
"or",
"equal",
"to",
"another"
] | 6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94 | https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-QName.php#L490-L495 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.