Make CSV reader return Row objects

This commit is contained in:
Adrien Loison committed 2017-11-18 19:08:27 +01:00
1 parent 139f7fdfb3
commit a665b974fa
37 files changed
+664 -214

No files matched your search

@@ -14,7 +14,7 @@ use Box\Spout\Writer\WriterInterface;
class EntityFactory
{
/**
* This creates an instance of the appropriate writer, given the type of the file to be read
* This creates an instance of the appropriate writer, given the type of the file to be written
*
* @param string $writerType Type of the writer to instantiate
* @throws \Box\Spout\Common\Exception\UnsupportedTypeException
+5 -5
View File
@@ -2,8 +2,8 @@
namespace Box\Spout\Writer\Common\Entity;
use Box\Spout\Common\Helper\CellTypeHelper;
use Box\Spout\Writer\Common\Entity\Style\Style;
use Box\Spout\Writer\Common\Helper\CellHelper;
/**
* Class Cell
@@ -118,16 +118,16 @@ class Cell
*/
protected function detectType($value)
{
if (CellHelper::isBoolean($value)) {
if (CellTypeHelper::isBoolean($value)) {
return self::TYPE_BOOLEAN;
}
if (CellHelper::isEmpty($value)) {
if (CellTypeHelper::isEmpty($value)) {
return self::TYPE_EMPTY;
}
if (CellHelper::isNumeric($this->getValue())) {
if (CellTypeHelper::isNumeric($this->getValue())) {
return self::TYPE_NUMERIC;
}
if (CellHelper::isNonEmptyString($value)) {
if (CellTypeHelper::isNonEmptyString($value)) {
return self::TYPE_STRING;
}
@@ -42,48 +42,4 @@ class CellHelper
return self::$columnIndexToCellIndexCache[$originalColumnIndex];
}
/**
* @param $value
* @return bool Whether the given value is considered "empty"
*/
public static function isEmpty($value)
{
return ($value === null || $value === '');
}
/**
* @param $value
* @return bool Whether the given value is a non empty string
*/
public static function isNonEmptyString($value)
{
return (gettype($value) === 'string' && $value !== '');
}
/**
* Returns whether the given value is numeric.
* A numeric value is from type "integer" or "double" ("float" is not returned by gettype).
*
* @param $value
* @return bool Whether the given value is numeric
*/
public static function isNumeric($value)
{
$valueType = gettype($value);
return ($valueType === 'integer' || $valueType === 'double');
}
/**
* Returns whether the given value is boolean.
* "true"/"false" and 0/1 are not booleans.
*
* @param $value
* @return bool Whether the given value is boolean
*/
public static function isBoolean($value)
{
return gettype($value) === 'boolean';
}
}