You are here

private function testDataFileIterator::_parseDataValue in Loft Data Grids 7.2

Same name and namespace in other branches
  1. 6.2 vendor/phpoffice/phpexcel/unitTests/testDataFileIterator.php \testDataFileIterator::_parseDataValue()
1 call to testDataFileIterator::_parseDataValue()
testDataFileIterator::_parseNextDataset in vendor/phpoffice/phpexcel/unitTests/testDataFileIterator.php

File

vendor/phpoffice/phpexcel/unitTests/testDataFileIterator.php, line 88

Class

testDataFileIterator

Code

private function _parseDataValue($dataValue) {

  //    discard any white space
  $dataValue = trim($dataValue);

  //    test for the required datatype and convert accordingly
  if (!is_numeric($dataValue)) {
    if ($dataValue == '') {
      $dataValue = NULL;
    }
    elseif ($dataValue == '""') {
      $dataValue = '';
    }
    elseif ($dataValue[0] == '"' && $dataValue[strlen($dataValue) - 1] == '"') {
      $dataValue = substr($dataValue, 1, -1);
    }
    elseif ($dataValue[0] == '{' && $dataValue[strlen($dataValue) - 1] == '}') {
      $dataValue = explode(';', substr($dataValue, 1, -1));
      foreach ($dataValue as &$dataRow) {
        if (strpos($dataRow, '|') !== FALSE) {
          $dataRow = explode('|', $dataRow);
          foreach ($dataRow as &$dataCell) {
            $dataCell = $this
              ->_parseDataValue($dataCell);
          }
          unset($dataCell);
        }
        else {
          $dataRow = $this
            ->_parseDataValue($dataRow);
        }
      }
      unset($dataRow);
    }
    else {
      switch (strtoupper($dataValue)) {
        case 'NULL':
          $dataValue = NULL;
          break;
        case 'TRUE':
          $dataValue = TRUE;
          break;
        case 'FALSE':
          $dataValue = FALSE;
          break;
      }
    }
  }
  else {
    if (strpos($dataValue, '.') !== FALSE) {
      $dataValue = (double) $dataValue;
    }
    else {
      $dataValue = (int) $dataValue;
    }
  }
  return $dataValue;
}