Add support to text starting with zeros (#8)

* add support to text starting with zeros

* Update src/Spout/Writer/Common/Helper/CellHelper.php

* Update src/Spout/Writer/Common/Helper/CellHelper.php
This commit is contained in:
Dariel Ramos 2020-04-17 16:13:40 -04:00 committed by GitHub
parent 68a2d71e3b
commit ecf5aafe9c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -69,11 +69,11 @@ class CellHelper
* A numeric value is from type "integer" or "double" ("float" is not returned by gettype). * A numeric value is from type "integer" or "double" ("float" is not returned by gettype).
* *
* @param $value * @param $value
* @return bool Whether the given value is numeric * @return bool Whether the given value is numeric and not start with zeros
*/ */
public static function isNumeric($value) public static function isNumeric($value)
{ {
return preg_match('#^-?\d+\.?\d*$#', $value) === 1; return preg_match('#^0\d+$#', $value) === 0 && $value == (string) ((float) $value);
} }
/** /**