Make CSV reader return Row objects
This commit is contained in:
1 parent
139f7fdfb3
commit
a665b974fa
37 files changed
+664
-214
No files matched your search
+18
-3
@@ -5,7 +5,9 @@ namespace Box\Spout\Reader\CSV\Creator;
|
||||
use Box\Spout\Common\Creator\HelperFactory;
|
||||
use Box\Spout\Common\Helper\GlobalFunctionsHelper;
|
||||
use Box\Spout\Common\Manager\OptionsManagerInterface;
|
||||
use Box\Spout\Reader\Common\Creator\EntityFactoryInterface;
|
||||
use Box\Spout\Reader\Common\Creator\InternalEntityFactoryInterface;
|
||||
use Box\Spout\Reader\Common\Entity\Cell;
|
||||
use Box\Spout\Reader\Common\Entity\Row;
|
||||
use Box\Spout\Reader\CSV\RowIterator;
|
||||
use Box\Spout\Reader\CSV\Sheet;
|
||||
use Box\Spout\Reader\CSV\SheetIterator;
|
||||
@@ -14,7 +16,7 @@ use Box\Spout\Reader\CSV\SheetIterator;
|
||||
* Class EntityFactory
|
||||
* Factory to create entities
|
||||
*/
|
||||
class EntityFactory implements EntityFactoryInterface
|
||||
class InternalEntityFactory implements InternalEntityFactoryInterface
|
||||
{
|
||||
/** @var HelperFactory */
|
||||
private $helperFactory;
|
||||
@@ -60,6 +62,19 @@ class EntityFactory implements EntityFactoryInterface
|
||||
{
|
||||
$encodingHelper = $this->helperFactory->createEncodingHelper($globalFunctionsHelper);
|
||||
|
||||
return new RowIterator($filePointer, $optionsManager, $encodingHelper, $globalFunctionsHelper);
|
||||
return new RowIterator($filePointer, $optionsManager, $encodingHelper, $this, $globalFunctionsHelper);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $cellValues
|
||||
* @return Row
|
||||
*/
|
||||
public function createRowFromArray(array $cellValues = [])
|
||||
{
|
||||
$cells = array_map(function ($cellValue) {
|
||||
return new Cell($cellValue);
|
||||
}, $cellValues);
|
||||
|
||||
return new Row($cells);
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ namespace Box\Spout\Reader\CSV;
|
||||
|
||||
use Box\Spout\Common\Exception\IOException;
|
||||
use Box\Spout\Reader\Common\Entity\Options;
|
||||
use Box\Spout\Reader\CSV\Creator\EntityFactory;
|
||||
use Box\Spout\Reader\CSV\Creator\InternalEntityFactory;
|
||||
use Box\Spout\Reader\ReaderAbstract;
|
||||
|
||||
/**
|
||||
@@ -92,7 +92,7 @@ class Reader extends ReaderAbstract
|
||||
throw new IOException("Could not open file $filePath for reading.");
|
||||
}
|
||||
|
||||
/** @var EntityFactory $entityFactory */
|
||||
/** @var InternalEntityFactory $entityFactory */
|
||||
$entityFactory = $this->entityFactory;
|
||||
|
||||
$this->sheetIterator = $entityFactory->createSheetIterator(
|
||||
|
||||
@@ -3,7 +3,11 @@
|
||||
namespace Box\Spout\Reader\CSV;
|
||||
|
||||
use Box\Spout\Common\Helper\EncodingHelper;
|
||||
use Box\Spout\Common\Helper\GlobalFunctionsHelper;
|
||||
use Box\Spout\Common\Manager\OptionsManagerInterface;
|
||||
use Box\Spout\Reader\Common\Entity\Options;
|
||||
use Box\Spout\Reader\Common\Entity\Row;
|
||||
use Box\Spout\Reader\CSV\Creator\InternalEntityFactory;
|
||||
use Box\Spout\Reader\IteratorInterface;
|
||||
|
||||
/**
|
||||
@@ -23,7 +27,7 @@ class RowIterator implements IteratorInterface
|
||||
/** @var int Number of read rows */
|
||||
protected $numReadRows = 0;
|
||||
|
||||
/** @var array|null Buffer used to store the row data, while checking if there are more rows to read */
|
||||
/** @var Row|null Buffer used to store the row data, while checking if there are more rows to read */
|
||||
protected $rowDataBuffer;
|
||||
|
||||
/** @var bool Indicates whether all rows have been read */
|
||||
@@ -41,26 +45,36 @@ class RowIterator implements IteratorInterface
|
||||
/** @var bool Whether empty rows should be returned or skipped */
|
||||
protected $shouldPreserveEmptyRows;
|
||||
|
||||
/** @var \Box\Spout\Common\Helper\GlobalFunctionsHelper Helper to work with global functions */
|
||||
protected $globalFunctionsHelper;
|
||||
|
||||
/** @var \Box\Spout\Common\Helper\EncodingHelper Helper to work with different encodings */
|
||||
protected $encodingHelper;
|
||||
|
||||
/** @var \Box\Spout\Reader\CSV\Creator\InternalEntityFactory Factory to create entities */
|
||||
protected $entityFactory;
|
||||
|
||||
/** @var \Box\Spout\Common\Helper\GlobalFunctionsHelper Helper to work with global functions */
|
||||
protected $globalFunctionsHelper;
|
||||
|
||||
/**
|
||||
* @param resource $filePointer Pointer to the CSV file to read
|
||||
* @param \Box\Spout\Common\Manager\OptionsManagerInterface $optionsManager
|
||||
* @param \Box\Spout\Common\Helper\EncodingHelper $encodingHelper
|
||||
* @param \Box\Spout\Common\Helper\GlobalFunctionsHelper $globalFunctionsHelper
|
||||
* @param OptionsManagerInterface $optionsManager
|
||||
* @param EncodingHelper $encodingHelper
|
||||
* @param InternalEntityFactory $entityFactory
|
||||
* @param GlobalFunctionsHelper $globalFunctionsHelper
|
||||
*/
|
||||
public function __construct($filePointer, $optionsManager, $encodingHelper, $globalFunctionsHelper)
|
||||
{
|
||||
public function __construct(
|
||||
$filePointer,
|
||||
OptionsManagerInterface $optionsManager,
|
||||
EncodingHelper $encodingHelper,
|
||||
InternalEntityFactory $entityFactory,
|
||||
GlobalFunctionsHelper $globalFunctionsHelper
|
||||
) {
|
||||
$this->filePointer = $filePointer;
|
||||
$this->fieldDelimiter = $optionsManager->getOption(Options::FIELD_DELIMITER);
|
||||
$this->fieldEnclosure = $optionsManager->getOption(Options::FIELD_ENCLOSURE);
|
||||
$this->encoding = $optionsManager->getOption(Options::ENCODING);
|
||||
$this->shouldPreserveEmptyRows = $optionsManager->getOption(Options::SHOULD_PRESERVE_EMPTY_ROWS);
|
||||
$this->encodingHelper = $encodingHelper;
|
||||
$this->entityFactory = $entityFactory;
|
||||
$this->globalFunctionsHelper = $globalFunctionsHelper;
|
||||
}
|
||||
|
||||
@@ -133,7 +147,8 @@ class RowIterator implements IteratorInterface
|
||||
|
||||
if ($rowData !== false) {
|
||||
// str_replace will replace NULL values by empty strings
|
||||
$this->rowDataBuffer = str_replace(null, null, $rowData);
|
||||
$rowDataBufferAsArray = str_replace(null, null, $rowData);
|
||||
$this->rowDataBuffer = $this->entityFactory->createRowFromArray($rowDataBufferAsArray);
|
||||
$this->numReadRows++;
|
||||
} else {
|
||||
// If we reach this point, it means end of file was reached.
|
||||
@@ -207,7 +222,7 @@ class RowIterator implements IteratorInterface
|
||||
* Return the current element from the buffer
|
||||
* @see http://php.net/manual/en/iterator.current.php
|
||||
*
|
||||
* @return array|null
|
||||
* @return Row|null
|
||||
*/
|
||||
public function current()
|
||||
{
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Box\Spout\Reader\Common\Creator;
|
||||
|
||||
use Box\Spout\Reader\ReaderFactory;
|
||||
use Box\Spout\Reader\ReaderInterface;
|
||||
|
||||
/**
|
||||
* Class EntityFactory
|
||||
* Factory to create external entities
|
||||
*/
|
||||
class EntityFactory
|
||||
{
|
||||
/**
|
||||
* This creates an instance of the appropriate reader, given the type of the file to be read
|
||||
*
|
||||
* @param string $readerType Type of the reader to instantiate
|
||||
* @throws \Box\Spout\Common\Exception\UnsupportedTypeException
|
||||
* @return ReaderInterface
|
||||
*/
|
||||
public static function createReader($readerType)
|
||||
{
|
||||
return (new ReaderFactory())->create($readerType);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -5,6 +5,6 @@ namespace Box\Spout\Reader\Common\Creator;
|
||||
/**
|
||||
* Interface EntityFactoryInterface
|
||||
*/
|
||||
interface EntityFactoryInterface
|
||||
interface InternalEntityFactoryInterface
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,159 @@
|
||||
<?php
|
||||
|
||||
namespace Box\Spout\Reader\Common\Entity;
|
||||
|
||||
use Box\Spout\Common\Helper\CellTypeHelper;
|
||||
|
||||
/**
|
||||
* Class Cell
|
||||
*/
|
||||
class Cell
|
||||
{
|
||||
/**
|
||||
* Numeric cell type (whole numbers, fractional numbers, dates)
|
||||
*/
|
||||
const TYPE_NUMERIC = 0;
|
||||
|
||||
/**
|
||||
* String (text) cell type
|
||||
*/
|
||||
const TYPE_STRING = 1;
|
||||
|
||||
/**
|
||||
* Formula cell type
|
||||
* Not used at the moment
|
||||
*/
|
||||
const TYPE_FORMULA = 2;
|
||||
|
||||
/**
|
||||
* Empty cell type
|
||||
*/
|
||||
const TYPE_EMPTY = 3;
|
||||
|
||||
/**
|
||||
* Boolean cell type
|
||||
*/
|
||||
const TYPE_BOOLEAN = 4;
|
||||
|
||||
/**
|
||||
* Error cell type
|
||||
*/
|
||||
const TYPE_ERROR = 5;
|
||||
|
||||
/**
|
||||
* The value of this cell
|
||||
* @var mixed|null
|
||||
*/
|
||||
protected $value;
|
||||
|
||||
/**
|
||||
* The cell type
|
||||
* @var int|null
|
||||
*/
|
||||
protected $type;
|
||||
|
||||
/**
|
||||
* @param $value mixed
|
||||
*/
|
||||
public function __construct($value)
|
||||
{
|
||||
$this->setValue($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed|null $value
|
||||
*/
|
||||
public function setValue($value)
|
||||
{
|
||||
$this->value = $value;
|
||||
$this->type = $this->detectType($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed|null
|
||||
*/
|
||||
public function getValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current value type
|
||||
*
|
||||
* @param mixed|null $value
|
||||
* @return int
|
||||
*/
|
||||
protected function detectType($value)
|
||||
{
|
||||
if (CellTypeHelper::isBoolean($value)) {
|
||||
return self::TYPE_BOOLEAN;
|
||||
}
|
||||
if (CellTypeHelper::isEmpty($value)) {
|
||||
return self::TYPE_EMPTY;
|
||||
}
|
||||
if (CellTypeHelper::isNumeric($this->getValue())) {
|
||||
return self::TYPE_NUMERIC;
|
||||
}
|
||||
if (CellTypeHelper::isNonEmptyString($value)) {
|
||||
return self::TYPE_STRING;
|
||||
}
|
||||
|
||||
return self::TYPE_ERROR;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isBoolean()
|
||||
{
|
||||
return $this->type === self::TYPE_BOOLEAN;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isEmpty()
|
||||
{
|
||||
return $this->type === self::TYPE_EMPTY;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isNumeric()
|
||||
{
|
||||
return $this->type === self::TYPE_NUMERIC;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isString()
|
||||
{
|
||||
return $this->type === self::TYPE_STRING;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isError()
|
||||
{
|
||||
return $this->type === self::TYPE_ERROR;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return (string) $this->value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace Box\Spout\Reader\Common\Entity;
|
||||
|
||||
class Row
|
||||
{
|
||||
/**
|
||||
* The cells in this row
|
||||
* @var Cell[]
|
||||
*/
|
||||
protected $cells = [];
|
||||
|
||||
/**
|
||||
* Row constructor.
|
||||
* @param Cell[] $cells
|
||||
*/
|
||||
public function __construct(array $cells)
|
||||
{
|
||||
$this->setCells($cells);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Cell[] $cells
|
||||
*/
|
||||
public function getCells()
|
||||
{
|
||||
return $this->cells;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Cell[] $cells
|
||||
* @return $this
|
||||
*/
|
||||
public function setCells(array $cells)
|
||||
{
|
||||
$this->cells = [];
|
||||
foreach ($cells as $cell) {
|
||||
$this->addCell($cell);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Cell $cell
|
||||
* @return Row
|
||||
*/
|
||||
public function addCell(Cell $cell)
|
||||
{
|
||||
$this->cells[] = $cell;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array The row values, as array
|
||||
*/
|
||||
public function toArray()
|
||||
{
|
||||
return array_map(function (Cell $cell) {
|
||||
return $cell->getValue();
|
||||
}, $this->cells);
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,7 @@ class HelperFactory extends \Box\Spout\Common\Creator\HelperFactory
|
||||
}
|
||||
|
||||
/**
|
||||
* @param EntityFactory $entityFactory
|
||||
* @param InternalEntityFactory $entityFactory
|
||||
* @return SettingsHelper
|
||||
*/
|
||||
public function createSettingsHelper($entityFactory)
|
||||
|
||||
+2
-2
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Box\Spout\Reader\ODS\Creator;
|
||||
|
||||
use Box\Spout\Reader\Common\Creator\EntityFactoryInterface;
|
||||
use Box\Spout\Reader\Common\Creator\InternalEntityFactoryInterface;
|
||||
use Box\Spout\Reader\Common\Entity\Options;
|
||||
use Box\Spout\Reader\Common\XMLProcessor;
|
||||
use Box\Spout\Reader\ODS\RowIterator;
|
||||
@@ -14,7 +14,7 @@ use Box\Spout\Reader\Wrapper\XMLReader;
|
||||
* Class EntityFactory
|
||||
* Factory to create entities
|
||||
*/
|
||||
class EntityFactory implements EntityFactoryInterface
|
||||
class InternalEntityFactory implements InternalEntityFactoryInterface
|
||||
{
|
||||
/** @var HelperFactory */
|
||||
private $helperFactory;
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace Box\Spout\Reader\ODS\Helper;
|
||||
|
||||
use Box\Spout\Reader\Exception\XMLProcessingException;
|
||||
use Box\Spout\Reader\ODS\Creator\EntityFactory;
|
||||
use Box\Spout\Reader\ODS\Creator\InternalEntityFactory;
|
||||
|
||||
/**
|
||||
* Class SettingsHelper
|
||||
@@ -18,11 +18,11 @@ class SettingsHelper
|
||||
const XML_ATTRIBUTE_CONFIG_NAME = 'config:name';
|
||||
const XML_ATTRIBUTE_VALUE_ACTIVE_TABLE = 'ActiveTable';
|
||||
|
||||
/** @var EntityFactory Factory to create entities */
|
||||
/** @var InternalEntityFactory Factory to create entities */
|
||||
private $entityFactory;
|
||||
|
||||
/**
|
||||
* @param EntityFactory $entityFactory Factory to create entities
|
||||
* @param InternalEntityFactory $entityFactory Factory to create entities
|
||||
*/
|
||||
public function __construct($entityFactory)
|
||||
{
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace Box\Spout\Reader\ODS;
|
||||
|
||||
use Box\Spout\Common\Exception\IOException;
|
||||
use Box\Spout\Reader\ODS\Creator\EntityFactory;
|
||||
use Box\Spout\Reader\ODS\Creator\InternalEntityFactory;
|
||||
use Box\Spout\Reader\ReaderAbstract;
|
||||
|
||||
/**
|
||||
@@ -38,13 +38,13 @@ class Reader extends ReaderAbstract
|
||||
*/
|
||||
protected function openReader($filePath)
|
||||
{
|
||||
/** @var EntityFactory $entityFactory */
|
||||
/** @var InternalEntityFactory $entityFactory */
|
||||
$entityFactory = $this->entityFactory;
|
||||
|
||||
$this->zip = $entityFactory->createZipArchive();
|
||||
|
||||
if ($this->zip->open($filePath) === true) {
|
||||
/** @var EntityFactory $entityFactory */
|
||||
/** @var InternalEntityFactory $entityFactory */
|
||||
$entityFactory = $this->entityFactory;
|
||||
$this->sheetIterator = $entityFactory->createSheetIterator($filePath, $this->optionsManager);
|
||||
} else {
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace Box\Spout\Reader\ODS;
|
||||
use Box\Spout\Common\Exception\IOException;
|
||||
use Box\Spout\Reader\Exception\XMLProcessingException;
|
||||
use Box\Spout\Reader\IteratorInterface;
|
||||
use Box\Spout\Reader\ODS\Creator\EntityFactory;
|
||||
use Box\Spout\Reader\ODS\Creator\InternalEntityFactory;
|
||||
use Box\Spout\Reader\ODS\Helper\SettingsHelper;
|
||||
use Box\Spout\Reader\Wrapper\XMLReader;
|
||||
|
||||
@@ -34,7 +34,7 @@ class SheetIterator implements IteratorInterface
|
||||
/** @var \Box\Spout\Common\Manager\OptionsManagerInterface Reader's options manager */
|
||||
protected $optionsManager;
|
||||
|
||||
/** @var EntityFactory $entityFactory Factory to create entities */
|
||||
/** @var InternalEntityFactory $entityFactory Factory to create entities */
|
||||
protected $entityFactory;
|
||||
|
||||
/** @var XMLReader The XMLReader object that will help read sheet's XML data */
|
||||
@@ -60,7 +60,7 @@ class SheetIterator implements IteratorInterface
|
||||
* @param \Box\Spout\Common\Manager\OptionsManagerInterface $optionsManager
|
||||
* @param \Box\Spout\Common\Helper\Escaper\ODS $escaper Used to unescape XML data
|
||||
* @param SettingsHelper $settingsHelper Helper to get data from "settings.xml"
|
||||
* @param EntityFactory $entityFactory Factory to create entities
|
||||
* @param InternalEntityFactory $entityFactory Factory to create entities
|
||||
*/
|
||||
public function __construct($filePath, $optionsManager, $escaper, $settingsHelper, $entityFactory)
|
||||
{
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace Box\Spout\Reader;
|
||||
use Box\Spout\Common\Exception\IOException;
|
||||
use Box\Spout\Common\Helper\GlobalFunctionsHelper;
|
||||
use Box\Spout\Common\Manager\OptionsManagerInterface;
|
||||
use Box\Spout\Reader\Common\Creator\EntityFactoryInterface;
|
||||
use Box\Spout\Reader\Common\Creator\InternalEntityFactoryInterface;
|
||||
use Box\Spout\Reader\Common\Entity\Options;
|
||||
use Box\Spout\Reader\Exception\ReaderNotOpenedException;
|
||||
|
||||
@@ -19,7 +19,7 @@ abstract class ReaderAbstract implements ReaderInterface
|
||||
/** @var bool Indicates whether the stream is currently open */
|
||||
protected $isStreamOpened = false;
|
||||
|
||||
/** @var EntityFactoryInterface Factory to create entities */
|
||||
/** @var InternalEntityFactoryInterface Factory to create entities */
|
||||
protected $entityFactory;
|
||||
|
||||
/** @var \Box\Spout\Common\Helper\GlobalFunctionsHelper Helper to work with global functions */
|
||||
@@ -60,12 +60,12 @@ abstract class ReaderAbstract implements ReaderInterface
|
||||
/**
|
||||
* @param OptionsManagerInterface $optionsManager
|
||||
* @param GlobalFunctionsHelper $globalFunctionsHelper
|
||||
* @param EntityFactoryInterface $entityFactory
|
||||
* @param InternalEntityFactoryInterface $entityFactory
|
||||
*/
|
||||
public function __construct(
|
||||
OptionsManagerInterface $optionsManager,
|
||||
GlobalFunctionsHelper $globalFunctionsHelper,
|
||||
EntityFactoryInterface $entityFactory
|
||||
InternalEntityFactoryInterface $entityFactory
|
||||
) {
|
||||
$this->optionsManager = $optionsManager;
|
||||
$this->globalFunctionsHelper = $globalFunctionsHelper;
|
||||
|
||||
@@ -39,7 +39,7 @@ class ReaderFactory
|
||||
{
|
||||
$optionsManager = new CSV\Manager\OptionsManager();
|
||||
$helperFactory = new HelperFactory();
|
||||
$entityFactory = new CSV\Creator\EntityFactory($helperFactory);
|
||||
$entityFactory = new CSV\Creator\InternalEntityFactory($helperFactory);
|
||||
$globalFunctionsHelper = $helperFactory->createGlobalFunctionsHelper();
|
||||
|
||||
return new CSV\Reader($optionsManager, $globalFunctionsHelper, $entityFactory);
|
||||
@@ -53,7 +53,7 @@ class ReaderFactory
|
||||
$optionsManager = new XLSX\Manager\OptionsManager();
|
||||
$helperFactory = new XLSX\Creator\HelperFactory();
|
||||
$managerFactory = new XLSX\Creator\ManagerFactory($helperFactory, new CachingStrategyFactory());
|
||||
$entityFactory = new XLSX\Creator\EntityFactory($managerFactory, $helperFactory);
|
||||
$entityFactory = new XLSX\Creator\InternalEntityFactory($managerFactory, $helperFactory);
|
||||
$globalFunctionsHelper = $helperFactory->createGlobalFunctionsHelper();
|
||||
|
||||
return new XLSX\Reader($optionsManager, $globalFunctionsHelper, $entityFactory, $managerFactory);
|
||||
@@ -66,7 +66,7 @@ class ReaderFactory
|
||||
{
|
||||
$optionsManager = new ODS\Manager\OptionsManager();
|
||||
$helperFactory = new ODS\Creator\HelperFactory();
|
||||
$entityFactory = new ODS\Creator\EntityFactory($helperFactory);
|
||||
$entityFactory = new ODS\Creator\InternalEntityFactory($helperFactory);
|
||||
$globalFunctionsHelper = $helperFactory->createGlobalFunctionsHelper();
|
||||
|
||||
return new ODS\Reader($optionsManager, $globalFunctionsHelper, $entityFactory);
|
||||
|
||||
+2
-3
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Box\Spout\Reader\XLSX\Creator;
|
||||
|
||||
use Box\Spout\Reader\Common\Creator\EntityFactoryInterface;
|
||||
use Box\Spout\Reader\Common\Creator\InternalEntityFactoryInterface;
|
||||
use Box\Spout\Reader\Common\Entity\Options;
|
||||
use Box\Spout\Reader\Common\XMLProcessor;
|
||||
use Box\Spout\Reader\Wrapper\XMLReader;
|
||||
@@ -10,13 +10,12 @@ use Box\Spout\Reader\XLSX\Manager\SharedStringsManager;
|
||||
use Box\Spout\Reader\XLSX\RowIterator;
|
||||
use Box\Spout\Reader\XLSX\Sheet;
|
||||
use Box\Spout\Reader\XLSX\SheetIterator;
|
||||
use MongoDB\Driver\Manager;
|
||||
|
||||
/**
|
||||
* Class EntityFactory
|
||||
* Factory to create entities
|
||||
*/
|
||||
class EntityFactory implements EntityFactoryInterface
|
||||
class InternalEntityFactory implements InternalEntityFactoryInterface
|
||||
{
|
||||
/** @var HelperFactory */
|
||||
private $helperFactory;
|
||||
@@ -36,7 +36,7 @@ class ManagerFactory
|
||||
/**
|
||||
* @param string $filePath Path of the XLSX file being read
|
||||
* @param string $tempFolder Temporary folder where the temporary files to store shared strings will be stored
|
||||
* @param EntityFactory $entityFactory Factory to create entities
|
||||
* @param InternalEntityFactory $entityFactory Factory to create entities
|
||||
* @return SharedStringsManager
|
||||
*/
|
||||
public function createSharedStringsManager($filePath, $tempFolder, $entityFactory)
|
||||
@@ -55,7 +55,7 @@ class ManagerFactory
|
||||
|
||||
/**
|
||||
* @param string $filePath Path of the XLSX file being read
|
||||
* @param EntityFactory $entityFactory Factory to create entities
|
||||
* @param InternalEntityFactory $entityFactory Factory to create entities
|
||||
* @return WorkbookRelationshipsManager
|
||||
*/
|
||||
private function createWorkbookRelationshipsManager($filePath, $entityFactory)
|
||||
@@ -71,7 +71,7 @@ class ManagerFactory
|
||||
* @param string $filePath Path of the XLSX file being read
|
||||
* @param \Box\Spout\Common\Manager\OptionsManagerInterface $optionsManager Reader's options manager
|
||||
* @param \Box\Spout\Reader\XLSX\Manager\SharedStringsManager $sharedStringsManager Manages shared strings
|
||||
* @param EntityFactory $entityFactory Factory to create entities
|
||||
* @param InternalEntityFactory $entityFactory Factory to create entities
|
||||
* @return SheetManager
|
||||
*/
|
||||
public function createSheetManager($filePath, $optionsManager, $sharedStringsManager, $entityFactory)
|
||||
@@ -83,7 +83,7 @@ class ManagerFactory
|
||||
|
||||
/**
|
||||
* @param string $filePath Path of the XLSX file being read
|
||||
* @param EntityFactory $entityFactory Factory to create entities
|
||||
* @param InternalEntityFactory $entityFactory Factory to create entities
|
||||
* @return StyleManager
|
||||
*/
|
||||
public function createStyleManager($filePath, $entityFactory)
|
||||
|
||||
@@ -5,8 +5,8 @@ namespace Box\Spout\Reader\XLSX\Manager;
|
||||
use Box\Spout\Common\Exception\IOException;
|
||||
use Box\Spout\Reader\Exception\XMLProcessingException;
|
||||
use Box\Spout\Reader\Wrapper\XMLReader;
|
||||
use Box\Spout\Reader\XLSX\Creator\EntityFactory;
|
||||
use Box\Spout\Reader\XLSX\Creator\HelperFactory;
|
||||
use Box\Spout\Reader\XLSX\Creator\InternalEntityFactory;
|
||||
use Box\Spout\Reader\XLSX\Manager\SharedStringsCaching\CachingStrategyFactory;
|
||||
use Box\Spout\Reader\XLSX\Manager\SharedStringsCaching\CachingStrategyInterface;
|
||||
use Box\Spout\Writer\Common\Entity\Workbook;
|
||||
@@ -41,7 +41,7 @@ class SharedStringsManager
|
||||
/** @var WorkbookRelationshipsManager Helps retrieving workbook relationships */
|
||||
protected $workbookRelationshipsManager;
|
||||
|
||||
/** @var EntityFactory Factory to create entities */
|
||||
/** @var InternalEntityFactory Factory to create entities */
|
||||
protected $entityFactory;
|
||||
|
||||
/** @var HelperFactory $helperFactory Factory to create helpers */
|
||||
@@ -57,7 +57,7 @@ class SharedStringsManager
|
||||
* @param string $filePath Path of the XLSX file being read
|
||||
* @param string $tempFolder Temporary folder where the temporary files to store shared strings will be stored
|
||||
* @param WorkbookRelationshipsManager $workbookRelationshipsManager Helps retrieving workbook relationships
|
||||
* @param EntityFactory $entityFactory Factory to create entities
|
||||
* @param InternalEntityFactory $entityFactory Factory to create entities
|
||||
* @param HelperFactory $helperFactory Factory to create helpers
|
||||
* @param CachingStrategyFactory $cachingStrategyFactory Factory to create shared strings caching strategies
|
||||
*/
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace Box\Spout\Reader\XLSX\Manager;
|
||||
|
||||
use Box\Spout\Reader\Common\Entity\Options;
|
||||
use Box\Spout\Reader\Common\XMLProcessor;
|
||||
use Box\Spout\Reader\XLSX\Creator\EntityFactory;
|
||||
use Box\Spout\Reader\XLSX\Creator\InternalEntityFactory;
|
||||
use Box\Spout\Reader\XLSX\Sheet;
|
||||
|
||||
/**
|
||||
@@ -48,7 +48,7 @@ class SheetManager
|
||||
/** @var \Box\Spout\Common\Helper\GlobalFunctionsHelper Helper to work with global functions */
|
||||
protected $globalFunctionsHelper;
|
||||
|
||||
/** @var EntityFactory Factory to create entities */
|
||||
/** @var InternalEntityFactory Factory to create entities */
|
||||
protected $entityFactory;
|
||||
|
||||
/** @var \Box\Spout\Common\Helper\Escaper\XLSX Used to unescape XML data */
|
||||
@@ -68,7 +68,7 @@ class SheetManager
|
||||
* @param \Box\Spout\Common\Manager\OptionsManagerInterface $optionsManager Reader's options manager
|
||||
* @param \Box\Spout\Reader\XLSX\Manager\SharedStringsManager $sharedStringsManager Manages shared strings
|
||||
* @param \Box\Spout\Common\Helper\Escaper\XLSX $escaper Used to unescape XML data
|
||||
* @param EntityFactory $entityFactory Factory to create entities
|
||||
* @param InternalEntityFactory $entityFactory Factory to create entities
|
||||
* @param mixed $sharedStringsManager
|
||||
*/
|
||||
public function __construct($filePath, $optionsManager, $sharedStringsManager, $escaper, $entityFactory)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Box\Spout\Reader\XLSX\Manager;
|
||||
|
||||
use Box\Spout\Reader\XLSX\Creator\EntityFactory;
|
||||
use Box\Spout\Reader\XLSX\Creator\InternalEntityFactory;
|
||||
|
||||
/**
|
||||
* Class StyleManager
|
||||
@@ -51,7 +51,7 @@ class StyleManager
|
||||
/** @var string Path of the styles XML file */
|
||||
protected $stylesXMLFilePath;
|
||||
|
||||
/** @var EntityFactory Factory to create entities */
|
||||
/** @var InternalEntityFactory Factory to create entities */
|
||||
protected $entityFactory;
|
||||
|
||||
/** @var array Array containing the IDs of built-in number formats indicating a date */
|
||||
@@ -69,7 +69,7 @@ class StyleManager
|
||||
/**
|
||||
* @param string $filePath Path of the XLSX file being read
|
||||
* @param WorkbookRelationshipsManager $workbookRelationshipsManager Helps retrieving workbook relationships
|
||||
* @param EntityFactory $entityFactory Factory to create entities
|
||||
* @param InternalEntityFactory $entityFactory Factory to create entities
|
||||
*/
|
||||
public function __construct($filePath, $workbookRelationshipsManager, $entityFactory)
|
||||
{
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace Box\Spout\Reader\XLSX\Manager;
|
||||
|
||||
use Box\Spout\Common\Exception\IOException;
|
||||
use Box\Spout\Reader\Wrapper\XMLReader;
|
||||
use Box\Spout\Reader\XLSX\Creator\EntityFactory;
|
||||
use Box\Spout\Reader\XLSX\Creator\InternalEntityFactory;
|
||||
|
||||
/**
|
||||
* Class WorkbookRelationshipsManager
|
||||
@@ -30,7 +30,7 @@ class WorkbookRelationshipsManager
|
||||
/** @var string Path of the XLSX file being read */
|
||||
private $filePath;
|
||||
|
||||
/** @var EntityFactory Factory to create entities */
|
||||
/** @var InternalEntityFactory Factory to create entities */
|
||||
private $entityFactory;
|
||||
|
||||
/** @var array Cache of the already read workbook relationships: [TYPE] => [FILE_NAME] */
|
||||
@@ -38,7 +38,7 @@ class WorkbookRelationshipsManager
|
||||
|
||||
/**
|
||||
* @param string $filePath Path of the XLSX file being read
|
||||
* @param EntityFactory $entityFactory Factory to create entities
|
||||
* @param InternalEntityFactory $entityFactory Factory to create entities
|
||||
*/
|
||||
public function __construct($filePath, $entityFactory)
|
||||
{
|
||||
|
||||
@@ -5,10 +5,10 @@ namespace Box\Spout\Reader\XLSX;
|
||||
use Box\Spout\Common\Exception\IOException;
|
||||
use Box\Spout\Common\Helper\GlobalFunctionsHelper;
|
||||
use Box\Spout\Common\Manager\OptionsManagerInterface;
|
||||
use Box\Spout\Reader\Common\Creator\EntityFactoryInterface;
|
||||
use Box\Spout\Reader\Common\Creator\InternalEntityFactoryInterface;
|
||||
use Box\Spout\Reader\Common\Entity\Options;
|
||||
use Box\Spout\Reader\ReaderAbstract;
|
||||
use Box\Spout\Reader\XLSX\Creator\EntityFactory;
|
||||
use Box\Spout\Reader\XLSX\Creator\InternalEntityFactory;
|
||||
use Box\Spout\Reader\XLSX\Creator\ManagerFactory;
|
||||
|
||||
/**
|
||||
@@ -32,13 +32,13 @@ class Reader extends ReaderAbstract
|
||||
/**
|
||||
* @param OptionsManagerInterface $optionsManager
|
||||
* @param GlobalFunctionsHelper $globalFunctionsHelper
|
||||
* @param EntityFactoryInterface $entityFactory
|
||||
* @param InternalEntityFactoryInterface $entityFactory
|
||||
* @param ManagerFactory $managerFactory
|
||||
*/
|
||||
public function __construct(
|
||||
OptionsManagerInterface $optionsManager,
|
||||
GlobalFunctionsHelper $globalFunctionsHelper,
|
||||
EntityFactoryInterface $entityFactory,
|
||||
InternalEntityFactoryInterface $entityFactory,
|
||||
ManagerFactory $managerFactory
|
||||
) {
|
||||
parent::__construct($optionsManager, $globalFunctionsHelper, $entityFactory);
|
||||
@@ -78,7 +78,7 @@ class Reader extends ReaderAbstract
|
||||
*/
|
||||
protected function openReader($filePath)
|
||||
{
|
||||
/** @var EntityFactory $entityFactory */
|
||||
/** @var InternalEntityFactory $entityFactory */
|
||||
$entityFactory = $this->entityFactory;
|
||||
|
||||
$this->zip = $entityFactory->createZipArchive();
|
||||
|
||||
Reference in new issue
Block a user