PSR2 Fixes
This commit is contained in:
parent
09352e3e80
commit
576effef30
File diff suppressed because it is too large
Load Diff
|
@ -557,9 +557,9 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'boolean':
|
case 'boolean':
|
||||||
$type = PHPExcel_Cell_DataType::TYPE_BOOL;
|
$type = PHPExcel_Cell_DataType::TYPE_BOOL;
|
||||||
$dataValue = ($allCellDataText == 'TRUE') ? true : false;
|
$dataValue = ($allCellDataText == 'TRUE') ? true : false;
|
||||||
break;
|
break;
|
||||||
case 'percentage':
|
case 'percentage':
|
||||||
$type = PHPExcel_Cell_DataType::TYPE_NUMERIC;
|
$type = PHPExcel_Cell_DataType::TYPE_NUMERIC;
|
||||||
$dataValue = (float) $cellDataOfficeAttributes['value'];
|
$dataValue = (float) $cellDataOfficeAttributes['value'];
|
||||||
|
|
|
@ -198,10 +198,14 @@ class PHPExcel_Shared_JAMA_Matrix
|
||||||
case 'integer,integer,integer,integer':
|
case 'integer,integer,integer,integer':
|
||||||
list($i0, $iF, $j0, $jF) = $args;
|
list($i0, $iF, $j0, $jF) = $args;
|
||||||
if (($iF > $i0) && ($this->m >= $iF) && ($i0 >= 0)) {
|
if (($iF > $i0) && ($this->m >= $iF) && ($i0 >= 0)) {
|
||||||
$m = $iF - $i0; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException);
|
$m = $iF - $i0;
|
||||||
|
} else {
|
||||||
|
throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException);
|
||||||
}
|
}
|
||||||
if (($jF > $j0) && ($this->n >= $jF) && ($j0 >= 0)) {
|
if (($jF > $j0) && ($this->n >= $jF) && ($j0 >= 0)) {
|
||||||
$n = $jF - $j0; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException);
|
$n = $jF - $j0;
|
||||||
|
} else {
|
||||||
|
throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException);
|
||||||
}
|
}
|
||||||
$R = new PHPExcel_Shared_JAMA_Matrix($m+1, $n+1);
|
$R = new PHPExcel_Shared_JAMA_Matrix($m+1, $n+1);
|
||||||
for ($i = $i0; $i <= $iF; ++$i) {
|
for ($i = $i0; $i <= $iF; ++$i) {
|
||||||
|
|
|
@ -17,21 +17,21 @@ date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
// Define path to application directory
|
// Define path to application directory
|
||||||
defined('APPLICATION_PATH')
|
defined('APPLICATION_PATH')
|
||||||
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../Classes'));
|
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../Classes'));
|
||||||
|
|
||||||
// Define path to application tests directory
|
// Define path to application tests directory
|
||||||
defined('APPLICATION_TESTS_PATH')
|
defined('APPLICATION_TESTS_PATH')
|
||||||
|| define('APPLICATION_TESTS_PATH', realpath(dirname(__FILE__) ));
|
|| define('APPLICATION_TESTS_PATH', realpath(dirname(__FILE__)));
|
||||||
|
|
||||||
// Define application environment
|
// Define application environment
|
||||||
defined('APPLICATION_ENV') || define('APPLICATION_ENV', 'ci');
|
defined('APPLICATION_ENV') || define('APPLICATION_ENV', 'ci');
|
||||||
|
|
||||||
// Ensure library/ is on include_path
|
// Ensure library/ is on include_path
|
||||||
set_include_path(implode(PATH_SEPARATOR, array(
|
set_include_path(implode(PATH_SEPARATOR, array(
|
||||||
realpath(APPLICATION_PATH . '/../Classes'),
|
realpath(APPLICATION_PATH . '/../Classes'),
|
||||||
'./',
|
'./',
|
||||||
dirname(__FILE__),
|
dirname(__FILE__),
|
||||||
get_include_path(),
|
get_include_path(),
|
||||||
)));
|
)));
|
||||||
|
|
||||||
|
|
||||||
|
@ -41,9 +41,9 @@ set_include_path(implode(PATH_SEPARATOR, array(
|
||||||
*/
|
*/
|
||||||
echo "PHPExcel tests beginning\n";
|
echo "PHPExcel tests beginning\n";
|
||||||
|
|
||||||
if(extension_loaded('xdebug')) {
|
if (extension_loaded('xdebug')) {
|
||||||
echo "Xdebug extension loaded and running\n";
|
echo "Xdebug extension loaded and running\n";
|
||||||
xdebug_enable();
|
xdebug_enable();
|
||||||
} else {
|
} else {
|
||||||
echo 'Xdebug not found, you should run the following at the command line: echo "zend_extension=/usr/lib64/php/modules/xdebug.so" > /etc/php.d/xdebug.ini' . "\n";
|
echo 'Xdebug not found, you should run the following at the command line: echo "zend_extension=/usr/lib64/php/modules/xdebug.so" > /etc/php.d/xdebug.ini' . "\n";
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,114 +1,115 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
class Complex {
|
class Complex
|
||||||
|
{
|
||||||
private $realPart = 0;
|
private $realPart = 0;
|
||||||
private $imaginaryPart = 0;
|
private $imaginaryPart = 0;
|
||||||
private $suffix = NULL;
|
private $suffix = null;
|
||||||
|
|
||||||
public static function _parseComplex($complexNumber)
|
public static function _parseComplex($complexNumber)
|
||||||
{
|
{
|
||||||
// Test for real number, with no imaginary part
|
// Test for real number, with no imaginary part
|
||||||
if (is_numeric($complexNumber))
|
if (is_numeric($complexNumber)) {
|
||||||
return array( $complexNumber, 0, NULL );
|
return array($complexNumber, 0, null);
|
||||||
|
}
|
||||||
// Fix silly human errors
|
|
||||||
if (strpos($complexNumber,'+-') !== FALSE)
|
// Fix silly human errors
|
||||||
$complexNumber = str_replace('+-','-',$complexNumber);
|
if (strpos($complexNumber, '+-') !== false) {
|
||||||
if (strpos($complexNumber,'++') !== FALSE)
|
$complexNumber = str_replace('+-', '-', $complexNumber);
|
||||||
$complexNumber = str_replace('++','+',$complexNumber);
|
}
|
||||||
if (strpos($complexNumber,'--') !== FALSE)
|
if (strpos($complexNumber, '++') !== false) {
|
||||||
$complexNumber = str_replace('--','-',$complexNumber);
|
$complexNumber = str_replace('++', '+', $complexNumber);
|
||||||
|
}
|
||||||
// Basic validation of string, to parse out real and imaginary parts, and any suffix
|
if (strpos($complexNumber, '--') !== false) {
|
||||||
$validComplex = preg_match('/^([\-\+]?(\d+\.?\d*|\d*\.?\d+)([Ee][\-\+]?[0-2]?\d{1,3})?)([\-\+]?(\d+\.?\d*|\d*\.?\d+)([Ee][\-\+]?[0-2]?\d{1,3})?)?(([\-\+]?)([ij]?))$/ui',$complexNumber,$complexParts);
|
$complexNumber = str_replace('--', '-', $complexNumber);
|
||||||
|
}
|
||||||
if (!$validComplex) {
|
|
||||||
// Neither real nor imaginary part, so test to see if we actually have a suffix
|
// Basic validation of string, to parse out real and imaginary parts, and any suffix
|
||||||
$validComplex = preg_match('/^([\-\+]?)([ij])$/ui',$complexNumber,$complexParts);
|
$validComplex = preg_match('/^([\-\+]?(\d+\.?\d*|\d*\.?\d+)([Ee][\-\+]?[0-2]?\d{1,3})?)([\-\+]?(\d+\.?\d*|\d*\.?\d+)([Ee][\-\+]?[0-2]?\d{1,3})?)?(([\-\+]?)([ij]?))$/ui', $complexNumber, $complexParts);
|
||||||
if (!$validComplex) {
|
|
||||||
throw new Exception('COMPLEX: Invalid complex number');
|
if (!$validComplex) {
|
||||||
}
|
// Neither real nor imaginary part, so test to see if we actually have a suffix
|
||||||
// We have a suffix, so set the real to 0, the imaginary to either 1 or -1 (as defined by the sign)
|
$validComplex = preg_match('/^([\-\+]?)([ij])$/ui', $complexNumber, $complexParts);
|
||||||
$imaginary = 1;
|
if (!$validComplex) {
|
||||||
if ($complexParts[1] === '-') {
|
throw new Exception('COMPLEX: Invalid complex number');
|
||||||
$imaginary = 0 - $imaginary;
|
}
|
||||||
}
|
// We have a suffix, so set the real to 0, the imaginary to either 1 or -1 (as defined by the sign)
|
||||||
return array(0, $imaginary, $complexParts[2]);
|
$imaginary = 1;
|
||||||
}
|
if ($complexParts[1] === '-') {
|
||||||
|
$imaginary = 0 - $imaginary;
|
||||||
// If we don't have an imaginary part, identify whether it should be +1 or -1...
|
}
|
||||||
if (($complexParts[4] === '') && ($complexParts[9] !== '')) {
|
return array(0, $imaginary, $complexParts[2]);
|
||||||
if ($complexParts[7] !== $complexParts[9]) {
|
}
|
||||||
$complexParts[4] = 1;
|
|
||||||
if ($complexParts[8] === '-') {
|
// If we don't have an imaginary part, identify whether it should be +1 or -1...
|
||||||
$complexParts[4] = -1;
|
if (($complexParts[4] === '') && ($complexParts[9] !== '')) {
|
||||||
}
|
if ($complexParts[7] !== $complexParts[9]) {
|
||||||
// ... or if we have only the real and no imaginary part (in which case our real should be the imaginary)
|
$complexParts[4] = 1;
|
||||||
} else {
|
if ($complexParts[8] === '-') {
|
||||||
$complexParts[4] = $complexParts[1];
|
$complexParts[4] = -1;
|
||||||
$complexParts[1] = 0;
|
}
|
||||||
}
|
// ... or if we have only the real and no imaginary part (in which case our real should be the imaginary)
|
||||||
}
|
} else {
|
||||||
|
$complexParts[4] = $complexParts[1];
|
||||||
// Return real and imaginary parts and suffix as an array, and set a default suffix if user input lazily
|
$complexParts[1] = 0;
|
||||||
return array( $complexParts[1],
|
}
|
||||||
$complexParts[4],
|
}
|
||||||
!empty($complexParts[9]) ? $complexParts[9] : 'i'
|
|
||||||
);
|
// Return real and imaginary parts and suffix as an array, and set a default suffix if user input lazily
|
||||||
} // function _parseComplex()
|
return array($complexParts[1], $complexParts[4], !empty($complexParts[9]) ? $complexParts[9] : 'i');
|
||||||
|
} // function _parseComplex()
|
||||||
|
|
||||||
public function __construct($realPart, $imaginaryPart = null, $suffix = 'i')
|
|
||||||
{
|
public function __construct($realPart, $imaginaryPart = null, $suffix = 'i')
|
||||||
if ($imaginaryPart === null) {
|
{
|
||||||
if (is_array($realPart)) {
|
if ($imaginaryPart === null) {
|
||||||
// We have an array of (potentially) real and imaginary parts, and any suffix
|
if (is_array($realPart)) {
|
||||||
list ($realPart, $imaginaryPart, $suffix) = array_values($realPart) + array(0.0, 0.0, 'i');
|
// We have an array of (potentially) real and imaginary parts, and any suffix
|
||||||
} elseif((is_string($realPart)) || (is_numeric($realPart))) {
|
list ($realPart, $imaginaryPart, $suffix) = array_values($realPart) + array(0.0, 0.0, 'i');
|
||||||
// We've been given a string to parse to extract the real and imaginary parts, and any suffix
|
} elseif((is_string($realPart)) || (is_numeric($realPart))) {
|
||||||
list ($realPart, $imaginaryPart, $suffix) = self::_parseComplex($realPart);
|
// We've been given a string to parse to extract the real and imaginary parts, and any suffix
|
||||||
}
|
list ($realPart, $imaginaryPart, $suffix) = self::_parseComplex($realPart);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Set parsed values in our properties
|
|
||||||
$this->realPart = (float) $realPart;
|
// Set parsed values in our properties
|
||||||
$this->imaginaryPart = (float) $imaginaryPart;
|
$this->realPart = (float) $realPart;
|
||||||
$this->suffix = strtolower($suffix);
|
$this->imaginaryPart = (float) $imaginaryPart;
|
||||||
}
|
$this->suffix = strtolower($suffix);
|
||||||
|
}
|
||||||
public function getReal()
|
|
||||||
{
|
public function getReal()
|
||||||
return $this->realPart;
|
{
|
||||||
}
|
return $this->realPart;
|
||||||
|
}
|
||||||
public function getImaginary()
|
|
||||||
{
|
public function getImaginary()
|
||||||
return $this->imaginaryPart;
|
{
|
||||||
}
|
return $this->imaginaryPart;
|
||||||
|
}
|
||||||
public function getSuffix()
|
|
||||||
{
|
public function getSuffix()
|
||||||
return $this->suffix;
|
{
|
||||||
}
|
return $this->suffix;
|
||||||
|
}
|
||||||
public function __toString() {
|
|
||||||
$str = "";
|
public function __toString() {
|
||||||
if ($this->imaginaryPart != 0.0) {
|
$str = "";
|
||||||
if (abs($this->imaginaryPart) != 1.0) {
|
if ($this->imaginaryPart != 0.0) {
|
||||||
$str .= $this->imaginaryPart . $this->suffix;
|
if (abs($this->imaginaryPart) != 1.0) {
|
||||||
} else {
|
$str .= $this->imaginaryPart . $this->suffix;
|
||||||
$str .= (($this->imaginaryPart < 0.0) ? '-' : ''). $this->suffix;
|
} else {
|
||||||
}
|
$str .= (($this->imaginaryPart < 0.0) ? '-' : ''). $this->suffix;
|
||||||
}
|
}
|
||||||
if ($this->realPart != 0.0) {
|
}
|
||||||
if (($str) && ($this->imaginaryPart > 0.0))
|
if ($this->realPart != 0.0) {
|
||||||
$str = "+" . $str;
|
if (($str) && ($this->imaginaryPart > 0.0))
|
||||||
$str = $this->realPart . $str;
|
$str = "+" . $str;
|
||||||
}
|
$str = $this->realPart . $str;
|
||||||
if (!$str)
|
}
|
||||||
$str = "0.0";
|
if (!$str)
|
||||||
return $str;
|
$str = "0.0";
|
||||||
}
|
return $str;
|
||||||
|
}
|
||||||
}
|
|
||||||
|
}
|
||||||
|
|
|
@ -1,62 +1,55 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
include_once dirname(__FILE__).'/Complex.php';
|
include_once dirname(__FILE__).'/Complex.php';
|
||||||
|
|
||||||
|
class complexAssert
|
||||||
class complexAssert {
|
{
|
||||||
|
private $_errorMessage = '';
|
||||||
private $_errorMessage = '';
|
|
||||||
|
public function assertComplexEquals($expected, $actual, $delta = 0)
|
||||||
public function assertComplexEquals($expected, $actual, $delta = 0)
|
{
|
||||||
{
|
if ($expected{0} === '#') {
|
||||||
if ($expected{0} === '#') {
|
// Expecting an error, so we do a straight string comparison
|
||||||
// Expecting an error, so we do a straight string comparison
|
if ($expected === $actual) {
|
||||||
if ($expected === $actual) {
|
return true;
|
||||||
return TRUE;
|
}
|
||||||
}
|
$this->_errorMessage = 'Expected Error: ' . $actual . ' !== ' . $expected;
|
||||||
$this->_errorMessage = 'Expected Error: ' .
|
return false;
|
||||||
$actual . ' !== ' . $expected;
|
}
|
||||||
return FALSE;
|
|
||||||
}
|
$expectedComplex = new Complex($expected);
|
||||||
|
$actualComplex = new Complex($actual);
|
||||||
$expectedComplex = new Complex($expected);
|
|
||||||
$actualComplex = new Complex($actual);
|
if (!is_numeric($actualComplex->getReal()) || !is_numeric($expectedComplex->getReal())) {
|
||||||
|
if ($actualComplex->getReal() !== $expectedComplex->getReal()) {
|
||||||
if (!is_numeric($actualComplex->getReal()) || !is_numeric($expectedComplex->getReal())) {
|
$this->_errorMessage = 'Mismatched String: ' . $actualComplex->getReal() . ' !== ' . $expectedComplex->getReal();
|
||||||
if ($actualComplex->getReal() !== $expectedComplex->getReal()) {
|
return false;
|
||||||
$this->_errorMessage = 'Mismatched String: ' .
|
}
|
||||||
$actualComplex->getReal() . ' !== ' . $expectedComplex->getReal();
|
return true;
|
||||||
return FALSE;
|
}
|
||||||
}
|
|
||||||
return TRUE;
|
if ($actualComplex->getReal() < ($expectedComplex->getReal() - $delta) ||
|
||||||
}
|
$actualComplex->getReal() > ($expectedComplex->getReal() + $delta)) {
|
||||||
|
$this->_errorMessage = 'Mismatched Real part: ' . $actualComplex->getReal() . ' != ' . $expectedComplex->getReal();
|
||||||
if ($actualComplex->getReal() < ($expectedComplex->getReal() - $delta) ||
|
return false;
|
||||||
$actualComplex->getReal() > ($expectedComplex->getReal() + $delta)) {
|
}
|
||||||
$this->_errorMessage = 'Mismatched Real part: ' .
|
|
||||||
$actualComplex->getReal() . ' != ' . $expectedComplex->getReal();
|
if ($actualComplex->getImaginary() < ($expectedComplex->getImaginary() - $delta) ||
|
||||||
return FALSE;
|
$actualComplex->getImaginary() > ($expectedComplex->getImaginary() + $delta)) {
|
||||||
}
|
$this->_errorMessage = 'Mismatched Imaginary part: ' . $actualComplex->getImaginary() . ' != ' . $expectedComplex->getImaginary();
|
||||||
|
return false;
|
||||||
if ($actualComplex->getImaginary() < ($expectedComplex->getImaginary() - $delta) ||
|
}
|
||||||
$actualComplex->getImaginary() > ($expectedComplex->getImaginary() + $delta)) {
|
|
||||||
$this->_errorMessage = 'Mismatched Imaginary part: ' .
|
if ($actualComplex->getSuffix() !== $actualComplex->getSuffix()) {
|
||||||
$actualComplex->getImaginary() . ' != ' . $expectedComplex->getImaginary();
|
$this->_errorMessage = 'Mismatched Suffix: ' . $actualComplex->getSuffix() . ' != ' . $expectedComplex->getSuffix();
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($actualComplex->getSuffix() !== $actualComplex->getSuffix()) {
|
return true;
|
||||||
$this->_errorMessage = 'Mismatched Suffix: ' .
|
}
|
||||||
$actualComplex->getSuffix() . ' != ' . $expectedComplex->getSuffix();
|
|
||||||
return FALSE;
|
public function getErrorMessage()
|
||||||
}
|
{
|
||||||
|
return $this->_errorMessage;
|
||||||
return TRUE;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function getErrorMessage() {
|
|
||||||
return $this->_errorMessage;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,137 +1,136 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
class testDataFileIterator implements Iterator
|
class testDataFileIterator implements Iterator
|
||||||
{
|
{
|
||||||
|
protected $file;
|
||||||
protected $file;
|
protected $key = 0;
|
||||||
protected $key = 0;
|
protected $current;
|
||||||
protected $current;
|
|
||||||
|
public function __construct($file)
|
||||||
public function __construct($file)
|
{
|
||||||
{
|
$this->file = fopen($file, 'r');
|
||||||
$this->file = fopen($file, 'r');
|
}
|
||||||
}
|
|
||||||
|
public function __destruct()
|
||||||
public function __destruct()
|
{
|
||||||
{
|
fclose($this->file);
|
||||||
fclose($this->file);
|
}
|
||||||
}
|
|
||||||
|
public function rewind()
|
||||||
public function rewind()
|
{
|
||||||
{
|
rewind($this->file);
|
||||||
rewind($this->file);
|
$this->current = $this->_parseNextDataset();
|
||||||
$this->current = $this->_parseNextDataset();
|
$this->key = 0;
|
||||||
$this->key = 0;
|
}
|
||||||
}
|
|
||||||
|
public function valid()
|
||||||
public function valid()
|
{
|
||||||
{
|
return !feof($this->file);
|
||||||
return !feof($this->file);
|
}
|
||||||
}
|
|
||||||
|
public function key()
|
||||||
public function key()
|
{
|
||||||
{
|
return $this->key;
|
||||||
return $this->key;
|
}
|
||||||
}
|
|
||||||
|
public function current()
|
||||||
public function current()
|
{
|
||||||
{
|
return $this->current;
|
||||||
return $this->current;
|
}
|
||||||
}
|
|
||||||
|
public function next()
|
||||||
public function next()
|
{
|
||||||
{
|
$this->current = $this->_parseNextDataset();
|
||||||
$this->current = $this->_parseNextDataset();
|
$this->key++;
|
||||||
$this->key++;
|
}
|
||||||
}
|
|
||||||
|
private function _parseNextDataset()
|
||||||
private function _parseNextDataset()
|
{
|
||||||
{
|
// Read a line of test data from the file
|
||||||
// Read a line of test data from the file
|
do {
|
||||||
do {
|
// Only take lines that contain test data and that aren't commented out
|
||||||
// Only take lines that contain test data and that aren't commented out
|
$testDataRow = trim(fgets($this->file));
|
||||||
$testDataRow = trim(fgets($this->file));
|
} while (($testDataRow > '') && ($testDataRow{0} === '#'));
|
||||||
} while (($testDataRow > '') && ($testDataRow{0} === '#'));
|
|
||||||
|
// Discard any comments at the end of the line
|
||||||
// Discard any comments at the end of the line
|
list($testData) = explode('//', $testDataRow);
|
||||||
list($testData) = explode('//', $testDataRow);
|
|
||||||
|
// Split data into an array of individual values and a result
|
||||||
// Split data into an array of individual values and a result
|
$dataSet = $this->_getcsv($testData, ',', "'");
|
||||||
$dataSet = $this->_getcsv($testData, ',', "'");
|
foreach ($dataSet as &$dataValue) {
|
||||||
foreach ($dataSet as &$dataValue) {
|
$dataValue = $this->_parseDataValue($dataValue);
|
||||||
$dataValue = $this->_parseDataValue($dataValue);
|
}
|
||||||
}
|
unset($dataValue);
|
||||||
unset($dataValue);
|
|
||||||
|
return $dataSet;
|
||||||
return $dataSet;
|
}
|
||||||
}
|
|
||||||
|
private function _getcsv($input, $delimiter, $enclosure)
|
||||||
private function _getcsv($input, $delimiter, $enclosure)
|
{
|
||||||
{
|
if (function_exists('str_getcsv')) {
|
||||||
if (function_exists('str_getcsv')) {
|
return str_getcsv($input, $delimiter, $enclosure);
|
||||||
return str_getcsv($input, $delimiter, $enclosure);
|
}
|
||||||
}
|
|
||||||
|
$temp = fopen('php://memory', 'rw');
|
||||||
$temp = fopen('php://memory', 'rw');
|
fwrite($temp, $input);
|
||||||
fwrite($temp, $input);
|
rewind($temp);
|
||||||
rewind($temp);
|
$data = fgetcsv($temp, strlen($input), $delimiter, $enclosure);
|
||||||
$data = fgetcsv($temp, strlen($input), $delimiter, $enclosure);
|
fclose($temp);
|
||||||
fclose($temp);
|
|
||||||
|
if ($data === false) {
|
||||||
if ($data === false) {
|
$data = array(null);
|
||||||
$data = array(null);
|
}
|
||||||
}
|
|
||||||
|
return $data;
|
||||||
return $data;
|
}
|
||||||
}
|
|
||||||
|
private function _parseDataValue($dataValue)
|
||||||
private function _parseDataValue($dataValue)
|
{
|
||||||
{
|
// discard any white space
|
||||||
// discard any white space
|
$dataValue = trim($dataValue);
|
||||||
$dataValue = trim($dataValue);
|
// test for the required datatype and convert accordingly
|
||||||
// test for the required datatype and convert accordingly
|
if (!is_numeric($dataValue)) {
|
||||||
if (!is_numeric($dataValue)) {
|
if($dataValue == '') {
|
||||||
if($dataValue == '') {
|
$dataValue = null;
|
||||||
$dataValue = null;
|
} elseif($dataValue == '""') {
|
||||||
} elseif($dataValue == '""') {
|
$dataValue = '';
|
||||||
$dataValue = '';
|
} elseif(($dataValue[0] == '"') && ($dataValue[strlen($dataValue)-1] == '"')) {
|
||||||
} elseif(($dataValue[0] == '"') && ($dataValue[strlen($dataValue)-1] == '"')) {
|
$dataValue = substr($dataValue,1,-1);
|
||||||
$dataValue = substr($dataValue,1,-1);
|
} elseif(($dataValue[0] == '{') && ($dataValue[strlen($dataValue)-1] == '}')) {
|
||||||
} elseif(($dataValue[0] == '{') && ($dataValue[strlen($dataValue)-1] == '}')) {
|
$dataValue = explode(';',substr($dataValue,1,-1));
|
||||||
$dataValue = explode(';',substr($dataValue,1,-1));
|
foreach ($dataValue as &$dataRow) {
|
||||||
foreach ($dataValue as &$dataRow) {
|
if (strpos($dataRow,'|') !== false) {
|
||||||
if (strpos($dataRow,'|') !== false) {
|
$dataRow = explode('|',$dataRow);
|
||||||
$dataRow = explode('|',$dataRow);
|
foreach ($dataRow as &$dataCell) {
|
||||||
foreach ($dataRow as &$dataCell) {
|
$dataCell = $this->_parseDataValue($dataCell);
|
||||||
$dataCell = $this->_parseDataValue($dataCell);
|
}
|
||||||
}
|
unset($dataCell);
|
||||||
unset($dataCell);
|
} else {
|
||||||
} else {
|
$dataRow = $this->_parseDataValue($dataRow);
|
||||||
$dataRow = $this->_parseDataValue($dataRow);
|
}
|
||||||
}
|
}
|
||||||
}
|
unset($dataRow);
|
||||||
unset($dataRow);
|
} else {
|
||||||
} else {
|
switch (strtoupper($dataValue)) {
|
||||||
switch (strtoupper($dataValue)) {
|
case 'NULL':
|
||||||
case 'NULL':
|
$dataValue = null;
|
||||||
$dataValue = null;
|
break;
|
||||||
break;
|
case 'TRUE':
|
||||||
case 'TRUE':
|
$dataValue = true;
|
||||||
$dataValue = true;
|
break;
|
||||||
break;
|
case 'FALSE':
|
||||||
case 'FALSE':
|
$dataValue = false;
|
||||||
$dataValue = false;
|
break;
|
||||||
break;
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
} else {
|
if (strpos($dataValue,'.') !== false) {
|
||||||
if (strpos($dataValue,'.') !== false) {
|
$dataValue = (float) $dataValue;
|
||||||
$dataValue = (float) $dataValue;
|
} else {
|
||||||
} else {
|
$dataValue = (int) $dataValue;
|
||||||
$dataValue = (int) $dataValue;
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
return $dataValue;
|
||||||
return $dataValue;
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue