Documentation

FactMapper
in package

FactMapper is responsible for transforming raw fact data into structured fact representations suitable for further processing.

Table of Contents

Properties

$contextBuilder  : ContextBuilder
$taxonomyReaderService  : TaxonomyReaderService
$unitBuilder  : UnitBuilder

Methods

__construct()  : mixed
Constructor method.
mapFact()  : array<string|int, mixed>
Maps a fact row to a structured fact representation.
mapFacts()  : array<string|int, mixed>
Maps an array of fact data rows to a structured format using the `mapFact` method.
detectFactType()  : string
Detects the type of a fact based on the provided concept and fact row data.
guessPrefixFromNamespace()  : string
Determines a prefix based on the provided namespace string.
looksNumericType()  : bool
Determines if the provided element type string suggests a numeric data type.
mapUnit()  : array<string|int, mixed>
Maps a fact row to a specific unit structure using the appropriate unit builder methods.
normalizeNumericValue()  : string
Normalizes a numeric value by converting it to a standardized string format.
toQName()  : string
Constructs a qualified name (QName) by combining the namespace prefix and the element name.

Properties

Methods

mapFact()

Maps a fact row to a structured fact representation.

public mapFact(array<string|int, mixed> $factRow) : array<string|int, mixed>
Parameters
$factRow : array<string|int, mixed>

The raw data row containing fact information. Expected keys include:

  • 'concept_element_id' (int): ID of the concept element.
  • 'entity_identifier' (string): Identifier of the entity.
  • 'entity_scheme' (string): Entity scheme.
  • 'period_start' (mixed): Start of the period (optional).
  • 'period_end' (mixed): End of the period (optional).
  • 'instant_date' (mixed): Instant date (optional).
  • 'dimensions' (array): Associated dimensions (optional).
  • 'decimals' (mixed): Decimals for the value (optional).
  • 'value' (mixed): Fact value.
  • 'datapoint_code' (mixed): Datapoint code (optional).
  • 'unit_code' (mixed): Unit code (optional).
Tags
throws
RuntimeException

If the concept element cannot be found based on the provided ID.

Return values
array<string|int, mixed> —

Structured fact representation. The returned array can contain:

  • 'type' (string): The type of the element ('fact').
  • 'fact_type' (string): Indicates whether the fact is 'nonFraction' or 'nonNumeric'.
  • 'name' (string): Qualified name of the fact.
  • 'context_ref' (string): Reference ID of the context.
  • 'unit_ref' (string): Reference ID of the unit (only for 'nonFraction' facts).
  • 'decimals' (mixed): Decimals for the fact value (only for 'nonFraction' facts).
  • 'value' (mixed): The fact value.
  • 'datapoint_code' (mixed): Datapoint code (optional, only for 'nonFraction' facts).
  • 'unit_code' (mixed): Unit code (optional, only for 'nonFraction' facts).

mapFacts()

Maps an array of fact data rows to a structured format using the `mapFact` method.

public mapFacts(array<string|int, mixed> $factRows) : array<string|int, mixed>
Parameters
$factRows : array<string|int, mixed>

An array of fact data rows to be transformed.

Return values
array<string|int, mixed> —

An array of mapped facts produced by the mapFact method.

detectFactType()

Detects the type of a fact based on the provided concept and fact row data.

private detectFactType(array<string|int, mixed> $concept, array<string|int, mixed> $factRow) : string
Parameters
$concept : array<string|int, mixed>

An associative array containing details about the concept, including its element_type.

$factRow : array<string|int, mixed>

An associative array representing a fact row, which may include keys like unit_measure and value.

Return values
string —

A string representing the detected fact type, either 'nonFraction' or 'nonNumeric'.

guessPrefixFromNamespace()

Determines a prefix based on the provided namespace string.

private guessPrefixFromNamespace(string $namespace) : string
Parameters
$namespace : string

A namespace string to analyze and extract a specific prefix from.

Return values
string —

The guessed prefix associated with the namespace, or an empty string if no match is found.

looksNumericType()

Determines if the provided element type string suggests a numeric data type.

private looksNumericType(string $elementType) : bool
Parameters
$elementType : string

The element type to analyze.

Return values
bool —

True if the element type contains indicators of a numeric data type; otherwise, false.

mapUnit()

Maps a fact row to a specific unit structure using the appropriate unit builder methods.

private mapUnit(array<string|int, mixed> $factRow) : array<string|int, mixed>
Parameters
$factRow : array<string|int, mixed>

An associative array representing the fact row to be transformed. It may contain keys like 'unit_measure', 'unit_numerator', and 'unit_denominator'.

Return values
array<string|int, mixed> —

A structured unit representation built by the unit builder.

normalizeNumericValue()

Normalizes a numeric value by converting it to a standardized string format.

private normalizeNumericValue(mixed $value) : string
Parameters
$value : mixed

The value to be normalized. Can be null, an empty string, a numeric string, or a number.

Return values
string —

The normalized numeric value as a string. Returns '0' for null or an empty string, trims and removes commas for string values, or converts numbers to string format.

toQName()

Constructs a qualified name (QName) by combining the namespace prefix and the element name.

private toQName(string $namespace, string $elementName) : string
Parameters
$namespace : string

The namespace URI to determine the prefix.

$elementName : string

The local name of the element.

Return values
string —

The qualified name consisting of the prefix and the element name, or just the element name if no prefix is determined.


        
On this page

Search results