You are here

private static function ChartDataCollectorTable::castValueToNumeric in Charts 8.4

Same name and namespace in other branches
  1. 5.0.x src/Element/ChartDataCollectorTable.php \Drupal\charts\Element\ChartDataCollectorTable::castValueToNumeric()

Casts string value to numeric.

Parameters

string $value: The value.

Return value

float|int The numeric value.

1 call to ChartDataCollectorTable::castValueToNumeric()
ChartDataCollectorTable::getSeriesFromCollectedTable in src/Element/ChartDataCollectorTable.php
Gets the series from the data collected by this element.

File

src/Element/ChartDataCollectorTable.php, line 847

Class

ChartDataCollectorTable
Provides a chart data collector table form element.

Namespace

Drupal\charts\Element

Code

private static function castValueToNumeric($value) {
  if (is_numeric($value)) {
    $value = is_int($value) ? (int) $value : (double) $value;
  }
  elseif ($value === '') {
    $value = NULL;
  }
  else {
    $value = 0;
  }
  return $value;
}