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
964397
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 );
	}
603295
protected function _createItem( array $entry )
	{
		$item = $this->_manager->createItem();

		foreach( $entry as $name => $value )
		{
			switch( $name )
			{
				case 'product.tag.id': $item->setId( $value ); break;
				case 'product.tag.label': $item->setLabel( $value ); break;
				case 'product.tag.typeid': $item->setTypeId( $value ); break;
				case 'product.tag.languageid':
					if( $value != '' ) {
						$item->setLanguageId( $value );
					}
					break;
			}
		}

		return $item;
	}
721086
public function getCastedValue($entry, $type)
    {
        switch ($type) {
            case IndexMapping::TYPE_BOOLEAN:
                if ($entry === "false") {
                    $entry = false;
                }
                $castedValue = (bool) $entry;
                break;

            case IndexMapping::TYPE_INTEGER:
                $castedValue = (int) $entry;
                break;

            case IndexMapping::TYPE_FLOAT:
                $castedValue = (float) $entry;
                break;

            case IndexMapping::TYPE_DATE:
                if ($entry instanceof \DateTime) {
                    $entry =  $entry->format("Y-m-d");
                }

                $castedValue = (string) $entry;
                break;

            case IndexMapping::TYPE_TIME:
                if ($entry instanceof \DateTime) {
                    $entry =  $entry->format("H:i:s");
                }

                $castedValue = (string) $entry;
                break;

            case IndexMapping::TYPE_DATETIME:
                if ($entry instanceof \DateTime) {
                    $entry =  $entry->format(\DateTime::ATOM);
                }

                $castedValue = (string) $entry;
                break;

            default:
            case IndexMapping::TYPE_STRING:
            case IndexMapping::TYPE_BIG_TEXT:
                $castedValue = (string) $entry;
        }

        return $castedValue;
    }
3096
private function assertEntryHasRequiredKeys(array $entry)
    {
        if (!isset($entry[ISO3166::KEY_ALPHA2])) {
            throw new DomainException('Each data entry must have a valid alpha2 key.');
        }

        Guards::guardAgainstInvalidAlpha2($entry[ISO3166::KEY_ALPHA2]);

        if (!isset($entry[ISO3166::KEY_ALPHA3])) {
            throw new DomainException('Each data entry must have a valid alpha3 key.');
        }

        Guards::guardAgainstInvalidAlpha3($entry[ISO3166::KEY_ALPHA3]);

        if (!isset($entry[ISO3166::KEY_NUMERIC])) {
            throw new DomainException('Each data entry must have a valid numeric key.');
        }

        Guards::guardAgainstInvalidNumeric($entry[ISO3166::KEY_NUMERIC]);
    }
144241
protected function validateClassEntry($entry)
    {
        if (!is_string($entry) && !is_object($entry)) {
            $type = gettype($entry);
            $message = sprintf('Argument "entry" in "%s" must be a string or an object; "%s" was given.', __METHOD__, $type);
            throw new Exception\InvalidArgumentException($message);
        }

        if (is_string($entry) && !class_exists($entry)) {
            throw new Exception\ClassNotFoundException($entry);
        }
    }
721469
public function format($mask, Entry $entry)
    {
        return $this->formatter->format($mask, function ($key) use ($entry) {
            if ($key === 'id') {
                return $entry->getID();
            }
            
            $attribute = $entry->getAttribute($key);
            if ($attribute) {
                return $attribute;
            }

            $association = $entry->getAssociation($key);
            if (is_object($association)) {
                return $association->getSelectedEntry()->getLabel();
            }
        });
    }
1259978
public function addEntry($entry)
	{
		// Set some default field values if not already set.
		$date = new AnDate();

		if (!isset ($entry['date'])) {
			$entry['date'] = $date->format("%Y-%m-%d");
		}

		if (!isset ($entry['time'])) {
			$entry['time'] = $date->format("%H:%M:%S");
		}

		if (!isset ($entry['c-ip'])) {
			$entry['c-ip'] = $_SERVER['REMOTE_ADDR'];
		}

		// Ensure that the log entry keys are all uppercase
		$entry = array_change_key_case($entry, CASE_UPPER);

		// Find all fields in the format string
		$fields = array ();
		$regex = "/{(.*?)}/i";
		preg_match_all($regex, $this->_format, $fields);

		// Fill in the field data
		$line = $this->_format;

		for ($i = 0; $i < count($fields[0]); $i++) {
			$line = str_replace($fields[0][$i], (isset ($entry[$fields[1][$i]])) ? $entry[$fields[1][$i]] : "-", $line);
		}

		// Write the log entry line
		if ($this->_openLog()) {
            return fputs($this->_file, "\n" . $line) ? true : false;
		}

        return false;
	}
1141423
private function formatRecords(array $entry)
    {
        $entries = str_split($entry['formatted'], self::EVENT_SIZE_LIMIT);
        $timestamp = $entry['datetime']->format('U.u') * 1000;
        $records = [];

        foreach ($entries as $entry) {
            $records[] = [
                'message' => $entry,
                'timestamp' => $timestamp
            ];
        }

        return $records;
    }
224532
public function generateValueSizeStatement($type, $value)
    {
        $metadata = $this->getComputeSizeMetadata($type);
        $method   = $metadata['method'];
        $size     = $metadata['size'];

        if ($size !== null) {
            return $size;
        }

        return sprintf('$calculator->%s(%s)', $method, $value);
    }
659579
private function sanitizeEntryStringValue(array $entry, $key)
    {
        return !empty($entry[$key]) ? htmlspecialchars($entry[$key], ENT_NOQUOTES) : '';
    }
458120
protected function _createItem( array $entry )
	{
		$item = $this->_manager->createItem();

		foreach( $entry as $name => $value )
		{
			switch( $name )
			{
				case 'order.base.id': $item->setId( $value ); break;
				case 'order.base.comment': $item->setComment( $value ); break;
				case 'order.base.customerid': $item->setCustomerId( $value ); break;
			}
		}

		return $item;
	}
1285079
private function getAmountFields(Source $source, array $entry)
    {
        $fields = array();
        if (!empty($entry['totalvalue']) && !empty($entry['totalvalueexclvat'])) {
            // Get Acumulus amounts.
            $amountExAcumulus = $entry['totalvalueexclvat'];
            $amountIncAcumulus = $entry['totalvalue'];
            $amountVatAcumulus = $amountIncAcumulus - $amountExAcumulus;

            // Get local amounts.
            $localTotals = $source->getTotals();

            // Compare.
            $amountExStatus = $this->getAmountStatus($amountExAcumulus, $localTotals[Meta::InvoiceAmount]);
            $amountIncStatus = $this->getAmountStatus($amountIncAcumulus, $localTotals[Meta::InvoiceAmountInc]);
            $amountVatStatus = $this->getAmountStatus($amountVatAcumulus, $localTotals[Meta::InvoiceVatAmount]);

            $amountEx = $this->getFormattedAmount($amountExAcumulus, $amountExStatus);
            $amountInc = $this->getFormattedAmount($amountIncAcumulus, $amountIncStatus);
            $amountVat = $this->getFormattedAmount($amountVatAcumulus, $amountVatStatus);

            $fields['invoice_amount'] = array(
                'type' => 'markup',
                'label' => $this->t('invoice_amount'),
                'value' => sprintf('<div class="acumulus-amount">%1$s%2$s %4$s%3$s</div>', $amountEx, $amountVat, $amountInc, $this->t('vat')),
            );
        }
        return $fields;
    }
585314
private function getValueAsString($value): string
    {
        if (is_bool($value)) {
            return $value ? 'true' : 'false';
        }

        if (is_float($value)) {
            $value = (string) $value;
            if (false === strpos($value, '.')) {
                $value .= '.0';
            }

            return $value;
        }

        if (is_int($value)) {
            return (string) $value;
        }

        throw new \InvalidArgumentException(sprintf('Unsupported data type: %s', gettype($value)));
    }
982739
public function get($entry)
    {
        $value = false;

        foreach ($this->caches as $cache) {
            $value = $cache->get($entry);
            if ($value !== false) {
                return $value;
            }
        }
        return $value;
    }
571702
protected function _createItem( array $entry )
	{
		$item = $this->_manager->createItem();

		foreach( $entry as $name => $value )
		{
			switch( $name )
			{
				case 'coupon.code.id': $item->setId( $value ); break;
				case 'coupon.code.code': $item->setCode( $value ); break;
				case 'coupon.code.count': $item->setCount( $value ); break;
				case 'coupon.code.couponid': $item->setCouponId( $value ); break;
				case 'coupon.code.datestart':
					if( $value != '' )
					{
						$value = str_replace( 'T', ' ', $value );
						$entry->{'coupon.code.datestart'} = $value;
						$item->setDateStart( $value );
					}
					break;
				case 'coupon.code.dateend':
					if( $value != '' )
					{
						$value = str_replace( 'T', ' ', $value );
						$entry->{'coupon.code.dateend'} = $value;
						$item->setDateEnd( $value );
					}
					break;
			}
		}

		return $item;
	}
43633
private static function getDecimalPrecision($value)
    {
        $lc = localeconv();

        $decimal_pos = mb_strpos((string) $value, $lc['decimal_point']);

        return $decimal_pos !== false
            ? mb_strlen($value) - $decimal_pos - mb_strlen($lc['decimal_point'])
            : 0;
    }
481691
protected function _createItem( array $entry )
	{
		$item = $this->_manager->createItem();

		foreach( $entry as $name => $value )
		{
			switch( $name )
			{
				case 'cache.id': $item->setId( $value ); break;
				case 'cache.value': $item->setValue( $value ); break;
				case 'cache.tags': $item->setTags( (array) $value ); break;
				case 'cache.expire':
					if( $value != '' )
					{
						$value = str_replace( 'T', ' ', $value );
						$entry->{'cache.expire'} = $value;
						$item->setTimeExpire( $value );
					}
					break;
			}
		}

		return $item;
	}