php-cs-fixer fix

This commit is contained in:
madflow 2017-10-04 13:32:54 +02:00
parent 8739bce698
commit 823fbdb43f
27 changed files with 90 additions and 79 deletions

View File

@ -83,8 +83,8 @@ class Writer extends WriterAbstract
* *
* @param Row $row The row containing cells and styles * @param Row $row The row containing cells and styles
* *
* @return void
* @throws IOException If unable to write data * @throws IOException If unable to write data
* @return void
* @internal param \Box\Spout\Writer\Common\Entity\Style\Style $style Ignored here since CSV does not support styling. * @internal param \Box\Spout\Writer\Common\Entity\Style\Style $style Ignored here since CSV does not support styling.
*/ */
protected function addRowToWriter(Row $row) protected function addRowToWriter(Row $row)

View File

@ -2,8 +2,8 @@
namespace Box\Spout\Writer\Common\Creator; namespace Box\Spout\Writer\Common\Creator;
use Box\Spout\Writer\Common\Entity\Row;
use Box\Spout\Writer\Common\Entity\Cell; use Box\Spout\Writer\Common\Entity\Cell;
use Box\Spout\Writer\Common\Entity\Row;
use Box\Spout\Writer\Common\Entity\Sheet; use Box\Spout\Writer\Common\Entity\Sheet;
use Box\Spout\Writer\Common\Entity\Style\Style; use Box\Spout\Writer\Common\Entity\Style\Style;
use Box\Spout\Writer\Common\Entity\Workbook; use Box\Spout\Writer\Common\Entity\Workbook;
@ -73,6 +73,7 @@ class EntityFactory
{ {
$styleMerger = new StyleMerger(); $styleMerger = new StyleMerger();
$rowManager = new RowManager($styleMerger); $rowManager = new RowManager($styleMerger);
return new Row($cells, $style, $rowManager); return new Row($cells, $style, $rowManager);
} }
} }

View File

@ -58,7 +58,7 @@ class Cell
* The cell style * The cell style
* @var Style|null * @var Style|null
*/ */
protected $style = null; protected $style;
/** /**
* @var StyleMerger * @var StyleMerger
@ -110,6 +110,7 @@ class Cell
if (!isset($this->style)) { if (!isset($this->style)) {
$this->setStyle(new Style()); $this->setStyle(new Style());
} }
return $this->style; return $this->style;
} }
@ -212,6 +213,7 @@ class Cell
} }
$mergedStyle = $this->styleMerger->merge($this->getStyle(), $style); $mergedStyle = $this->styleMerger->merge($this->getStyle(), $style);
$this->setStyle($mergedStyle); $this->setStyle($mergedStyle);
return $this; return $this;
} }
} }

View File

@ -4,7 +4,6 @@ namespace Box\Spout\Writer\Common\Entity;
use Box\Spout\Writer\Common\Entity\Style\Style; use Box\Spout\Writer\Common\Entity\Style\Style;
use Box\Spout\Writer\Common\Manager\RowManager; use Box\Spout\Writer\Common\Manager\RowManager;
use Box\Spout\Writer\Common\Manager\Style\StyleMerger;
class Row class Row
{ {
@ -16,9 +15,9 @@ class Row
/** /**
* The row style * The row style
* @var null|Style * @var Style|null
*/ */
protected $style = null; protected $style;
/** /**
* Thw row manager * Thw row manager
@ -59,6 +58,7 @@ class Row
foreach ($cells as $cell) { foreach ($cells as $cell) {
$this->addCell($cell); $this->addCell($cell);
} }
return $this; return $this;
} }
@ -70,6 +70,7 @@ class Row
if (!isset($this->style)) { if (!isset($this->style)) {
$this->setStyle(new Style()); $this->setStyle(new Style());
} }
return $this->style; return $this->style;
} }
@ -80,6 +81,7 @@ class Row
public function setStyle($style) public function setStyle($style)
{ {
$this->style = $style; $this->style = $style;
return $this; return $this;
} }
@ -90,6 +92,7 @@ class Row
public function applyStyle(Style $style = null) public function applyStyle(Style $style = null)
{ {
$this->rowManager->applyStyle($this, $style); $this->rowManager->applyStyle($this, $style);
return $this; return $this;
} }
@ -100,6 +103,7 @@ class Row
public function addCell(Cell $cell) public function addCell(Cell $cell)
{ {
$this->cells[] = $cell; $this->cells[] = $cell;
return $this; return $this;
} }

View File

@ -42,6 +42,7 @@ class RowManager
public function isEmpty(Row $row) public function isEmpty(Row $row)
{ {
$cells = $row->getCells(); $cells = $row->getCells();
return count($cells) === 0 || (count($cells) === 1 && $cells[0]->isEmpty()); return count($cells) === 0 || (count($cells) === 1 && $cells[0]->isEmpty());
} }
} }

View File

@ -55,6 +55,7 @@ class StyleManager implements StyleManagerInterface
public function applyExtraStylesIfNeeded(Cell $cell) public function applyExtraStylesIfNeeded(Cell $cell)
{ {
$updatedStyle = $this->applyWrapTextIfCellContainsNewLine($cell); $updatedStyle = $this->applyWrapTextIfCellContainsNewLine($cell);
return $updatedStyle; return $updatedStyle;
} }
@ -79,6 +80,7 @@ class StyleManager implements StyleManagerInterface
if ($cell->isString() && strpos($cell->getValue(), "\n") !== false) { if ($cell->isString() && strpos($cell->getValue(), "\n") !== false) {
$cell->getStyle()->setShouldWrapText(); $cell->getStyle()->setShouldWrapText();
} }
return $cell->getStyle(); return $cell->getStyle();
} }
} }

View File

@ -5,7 +5,6 @@ namespace Box\Spout\Writer\Common\Manager\Style;
use Box\Spout\Writer\Common\Entity\Cell; use Box\Spout\Writer\Common\Entity\Cell;
use Box\Spout\Writer\Common\Entity\Style\Style; use Box\Spout\Writer\Common\Entity\Style\Style;
/** /**
* Interface StyleHManagernterface * Interface StyleHManagernterface
*/ */

View File

@ -203,10 +203,10 @@ abstract class WorkbookManagerAbstract implements WorkbookManagerInterface
* with the creation of new worksheets if one worksheet has reached its maximum capicity. * with the creation of new worksheets if one worksheet has reached its maximum capicity.
* *
* @param Row $row The row to added * @param Row $row The row to added
* @return void
* @throws IOException If trying to create a new sheet and unable to open the sheet for writing * @throws IOException If trying to create a new sheet and unable to open the sheet for writing
* @throws WriterException If unable to write data * @throws WriterException If unable to write data
* @return void * @return void
* @return void
*/ */
public function addRowToCurrentWorksheet(Row $row) public function addRowToCurrentWorksheet(Row $row)
{ {
@ -243,9 +243,9 @@ abstract class WorkbookManagerAbstract implements WorkbookManagerInterface
* *
* @param Worksheet $worksheet Worksheet to write the row to * @param Worksheet $worksheet Worksheet to write the row to
* @param Row $row The row to be added * @param Row $row The row to be added
* @return void
* @throws WriterException If unable to write data * @throws WriterException If unable to write data
* @return void * @return void
* @return void
*/ */
private function addRowToWorksheet(Worksheet $worksheet, Row $row) private function addRowToWorksheet(Worksheet $worksheet, Row $row)
{ {

View File

@ -3,9 +3,8 @@
namespace Box\Spout\Writer\Common\Manager; namespace Box\Spout\Writer\Common\Manager;
use Box\Spout\Common\Exception\IOException; use Box\Spout\Common\Exception\IOException;
use Box\Spout\Writer\Common\Entity\Sheet;
use Box\Spout\Writer\Common\Entity\Style\Style;
use Box\Spout\Writer\Common\Entity\Row; use Box\Spout\Writer\Common\Entity\Row;
use Box\Spout\Writer\Common\Entity\Sheet;
use Box\Spout\Writer\Common\Entity\Workbook; use Box\Spout\Writer\Common\Entity\Workbook;
use Box\Spout\Writer\Common\Entity\Worksheet; use Box\Spout\Writer\Common\Entity\Worksheet;
use Box\Spout\Writer\Exception\SheetNotFoundException; use Box\Spout\Writer\Exception\SheetNotFoundException;
@ -59,12 +58,13 @@ interface WorkbookManagerInterface
* with the creation of new worksheets if one worksheet has reached its maximum capicity. * with the creation of new worksheets if one worksheet has reached its maximum capicity.
* *
* @param Row $row The row to added * @param Row $row The row to added
* @return void
* @throws IOException If trying to create a new sheet and unable to open the sheet for writing * @throws IOException If trying to create a new sheet and unable to open the sheet for writing
* @throws WriterException If unable to write data * @throws WriterException If unable to write data
* @return void * @return void
* @return void
*/ */
public function addRowToCurrentWorksheet(Row $row); public function addRowToCurrentWorksheet(Row $row);
/** /**
* Closes the workbook and all its associated sheets. * Closes the workbook and all its associated sheets.
* All the necessary files are written to disk and zipped together to create the final file. * All the necessary files are written to disk and zipped together to create the final file.

View File

@ -3,7 +3,6 @@
namespace Box\Spout\Writer\Common\Manager; namespace Box\Spout\Writer\Common\Manager;
use Box\Spout\Writer\Common\Entity\Row; use Box\Spout\Writer\Common\Entity\Row;
use Box\Spout\Writer\Common\Entity\Style\Style;
use Box\Spout\Writer\Common\Entity\Worksheet; use Box\Spout\Writer\Common\Entity\Worksheet;
/** /**
@ -17,10 +16,10 @@ interface WorksheetManagerInterface
* *
* @param Worksheet $worksheet The worksheet to add the row to * @param Worksheet $worksheet The worksheet to add the row to
* @param Row $row The row to be added * @param Row $row The row to be added
* @return void
* @throws \Box\Spout\Common\Exception\IOException If the data cannot be written * @throws \Box\Spout\Common\Exception\IOException If the data cannot be written
* @throws \Box\Spout\Common\Exception\InvalidArgumentException If a cell value's type is not supported * @throws \Box\Spout\Common\Exception\InvalidArgumentException If a cell value's type is not supported
* @return void * @return void
* @return void
*/ */
public function addRow(Worksheet $worksheet, Row $row); public function addRow(Worksheet $worksheet, Row $row);

View File

@ -68,8 +68,8 @@ class ManagerFactory implements ManagerFactoryInterface
$stringsEscaper = $this->helperFactory->createStringsEscaper(); $stringsEscaper = $this->helperFactory->createStringsEscaper();
$stringsHelper = $this->helperFactory->createStringHelper(); $stringsHelper = $this->helperFactory->createStringHelper();
return new WorksheetManager($styleManager, $stringsEscaper, $stringsHelper); return new WorksheetManager($styleManager, $stringsEscaper, $stringsHelper);
return new WorksheetManager($stringsEscaper, $stringsHelper, $this->entityFactory); return new WorksheetManager($stringsEscaper, $stringsHelper, $this->entityFactory);
} }

View File

@ -6,7 +6,6 @@ use Box\Spout\Common\Exception\InvalidArgumentException;
use Box\Spout\Common\Exception\IOException; use Box\Spout\Common\Exception\IOException;
use Box\Spout\Common\Helper\Escaper\ODS as ODSEscaper; use Box\Spout\Common\Helper\Escaper\ODS as ODSEscaper;
use Box\Spout\Common\Helper\StringHelper; use Box\Spout\Common\Helper\StringHelper;
use Box\Spout\Writer\Common\Creator\EntityFactory;
use Box\Spout\Writer\Common\Entity\Cell; use Box\Spout\Writer\Common\Entity\Cell;
use Box\Spout\Writer\Common\Entity\Row; use Box\Spout\Writer\Common\Entity\Row;
use Box\Spout\Writer\Common\Entity\Worksheet; use Box\Spout\Writer\Common\Entity\Worksheet;
@ -37,8 +36,8 @@ class WorksheetManager implements WorksheetManagerInterface
public function __construct( public function __construct(
StyleManager $styleManager, StyleManager $styleManager,
ODSEscaper $stringsEscaper, ODSEscaper $stringsEscaper,
StringHelper $stringHelper) StringHelper $stringHelper
{ ) {
$this->stringsEscaper = $stringsEscaper; $this->stringsEscaper = $stringsEscaper;
$this->stringHelper = $stringHelper; $this->stringHelper = $stringHelper;
$this->styleManager = $styleManager; $this->styleManager = $styleManager;
@ -96,15 +95,14 @@ class WorksheetManager implements WorksheetManagerInterface
* *
* @param Worksheet $worksheet The worksheet to add the row to * @param Worksheet $worksheet The worksheet to add the row to
* @param Row $row The row to be added * @param Row $row The row to be added
* @return void
*
* @throws IOException If the data cannot be written * @throws IOException If the data cannot be written
* @throws InvalidArgumentException If a cell value's type is not supported * @throws InvalidArgumentException If a cell value's type is not supported
* @return void * @return void
*
* @return void
*/ */
public function addRow(Worksheet $worksheet, Row $row) public function addRow(Worksheet $worksheet, Row $row)
{ {
$cells = $row->getCells(); $cells = $row->getCells();
$cellsCount = count($cells); $cellsCount = count($cells);
@ -114,15 +112,13 @@ class WorksheetManager implements WorksheetManagerInterface
$nextCellIndex = 1; $nextCellIndex = 1;
for ($i = 0; $i < $cellsCount; $i++) { for ($i = 0; $i < $cellsCount; $i++) {
/** @var Cell $cell */ /** @var Cell $cell */
$cell = $cells[$currentCellIndex]; $cell = $cells[$currentCellIndex];
/** @var Cell|null $nextCell */ /** @var Cell|null $nextCell */
$nextCell = isset($cells[$nextCellIndex]) ? $cells[$nextCellIndex] : null; $nextCell = isset($cells[$nextCellIndex]) ? $cells[$nextCellIndex] : null;
// @TODO refactoring: move this to its own method // @TODO refactoring: move this to its own method
if (null === $nextCell || $cell->getValue() !== $nextCell->getValue()) { if ($nextCell === null || $cell->getValue() !== $nextCell->getValue()) {
// Apply styles - the row style is merged at this point // Apply styles - the row style is merged at this point
$cell->applyStyle($row->getStyle()); $cell->applyStyle($row->getStyle());
$this->styleManager->applyExtraStylesIfNeeded($cell); $this->styleManager->applyExtraStylesIfNeeded($cell);

View File

@ -7,9 +7,9 @@ use Box\Spout\Common\Exception\InvalidArgumentException;
use Box\Spout\Common\Exception\IOException; use Box\Spout\Common\Exception\IOException;
use Box\Spout\Common\Exception\SpoutException; use Box\Spout\Common\Exception\SpoutException;
use Box\Spout\Common\Helper\GlobalFunctionsHelper; use Box\Spout\Common\Helper\GlobalFunctionsHelper;
use Box\Spout\Common\Manager\OptionsManagerInterface;
use Box\Spout\Writer\Common\Creator\EntityFactory; use Box\Spout\Writer\Common\Creator\EntityFactory;
use Box\Spout\Writer\Common\Entity\Cell; use Box\Spout\Writer\Common\Entity\Cell;
use Box\Spout\Common\Manager\OptionsManagerInterface;
use Box\Spout\Writer\Common\Entity\Options; use Box\Spout\Writer\Common\Entity\Options;
use Box\Spout\Writer\Common\Entity\Row; use Box\Spout\Writer\Common\Entity\Row;
use Box\Spout\Writer\Common\Entity\Style\Style; use Box\Spout\Writer\Common\Entity\Style\Style;
@ -98,11 +98,12 @@ abstract class WriterAbstract implements WriterInterface
public function setDefaultRowStyle($defaultStyle) public function setDefaultRowStyle($defaultStyle)
{ {
$this->optionsManager->setOption(Options::DEFAULT_ROW_STYLE, $defaultStyle); $this->optionsManager->setOption(Options::DEFAULT_ROW_STYLE, $defaultStyle);
return $this; return $this;
} }
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public function openToFile($outputFilePath) public function openToFile($outputFilePath)
{ {
@ -118,7 +119,7 @@ abstract class WriterAbstract implements WriterInterface
} }
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public function openToBrowser($outputFileName) public function openToBrowser($outputFileName)
{ {
@ -181,7 +182,7 @@ abstract class WriterAbstract implements WriterInterface
} }
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public function addRow(Row $row) public function addRow(Row $row)
{ {
@ -201,11 +202,12 @@ abstract class WriterAbstract implements WriterInterface
} else { } else {
throw new WriterNotOpenedException('The writer needs to be opened before adding row.'); throw new WriterNotOpenedException('The writer needs to be opened before adding row.');
} }
return $this; return $this;
} }
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public function withRow(\Closure $callback) public function withRow(\Closure $callback)
{ {
@ -213,12 +215,11 @@ abstract class WriterAbstract implements WriterInterface
} }
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public function addRows(array $dataRows) public function addRows(array $dataRows)
{ {
foreach ($dataRows as $dataRow) { foreach ($dataRows as $dataRow) {
if (!$dataRow instanceof Row) { if (!$dataRow instanceof Row) {
$this->closeAndAttemptToCleanupAllFiles(); $this->closeAndAttemptToCleanupAllFiles();
throw new InvalidArgumentException(); throw new InvalidArgumentException();
@ -226,6 +227,7 @@ abstract class WriterAbstract implements WriterInterface
$this->addRow($dataRow); $this->addRow($dataRow);
} }
return $this; return $this;
} }
@ -240,6 +242,7 @@ abstract class WriterAbstract implements WriterInterface
if ($value instanceof Cell) { if ($value instanceof Cell) {
return $value; return $value;
} }
return new Cell($value); return new Cell($value);
}, $dataRow)); }, $dataRow));
@ -259,7 +262,7 @@ abstract class WriterAbstract implements WriterInterface
private function applyDefaultRowStyle(Row $row) private function applyDefaultRowStyle(Row $row)
{ {
$defaultRowStyle = $this->optionsManager->getOption(Options::DEFAULT_ROW_STYLE); $defaultRowStyle = $this->optionsManager->getOption(Options::DEFAULT_ROW_STYLE);
if (null === $defaultRowStyle) { if ($defaultRowStyle === null) {
return $this; return $this;
} }
$mergedStyle = $this->styleMerger->merge($row->getStyle(), $defaultRowStyle); $mergedStyle = $this->styleMerger->merge($row->getStyle(), $defaultRowStyle);

View File

@ -2,7 +2,6 @@
namespace Box\Spout\Writer; namespace Box\Spout\Writer;
use Box\Spout\Common\Exception\IOException;
use Box\Spout\Writer\Common\Entity\Row; use Box\Spout\Writer\Common\Entity\Row;
/** /**
@ -50,11 +49,11 @@ interface WriterInterface
* Write a given array of rows to the output. New data will be appended to the end of the stream. * Write a given array of rows to the output. New data will be appended to the end of the stream.
* *
* @param Row[] $rows Array of rows be appended to the stream * @param Row[] $rows Array of rows be appended to the stream
* @return WriterInterface
* @throws \Box\Spout\Common\Exception\InvalidArgumentException If the input param is not valid * @throws \Box\Spout\Common\Exception\InvalidArgumentException If the input param is not valid
* @throws \Box\Spout\Writer\Exception\WriterNotOpenedException If the writer has not been opened yet * @throws \Box\Spout\Writer\Exception\WriterNotOpenedException If the writer has not been opened yet
* @throws \Box\Spout\Common\Exception\IOException If unable to write data * @throws \Box\Spout\Common\Exception\IOException If unable to write data
* @return WriterInterface * @return WriterInterface
* @return WriterInterface
*/ */
public function addRows(array $rows); public function addRows(array $rows);

View File

@ -7,8 +7,8 @@ use Box\Spout\Common\Helper\GlobalFunctionsHelper;
use Box\Spout\Common\Manager\OptionsManagerInterface; use Box\Spout\Common\Manager\OptionsManagerInterface;
use Box\Spout\Writer\Common\Creator\ManagerFactoryInterface; use Box\Spout\Writer\Common\Creator\ManagerFactoryInterface;
use Box\Spout\Writer\Common\Entity\Options; use Box\Spout\Writer\Common\Entity\Options;
use Box\Spout\Writer\Common\Entity\Sheet;
use Box\Spout\Writer\Common\Entity\Row; use Box\Spout\Writer\Common\Entity\Row;
use Box\Spout\Writer\Common\Entity\Sheet;
use Box\Spout\Writer\Common\Entity\Worksheet; use Box\Spout\Writer\Common\Entity\Worksheet;
use Box\Spout\Writer\Common\Manager\Style\StyleMerger; use Box\Spout\Writer\Common\Manager\Style\StyleMerger;
use Box\Spout\Writer\Common\Manager\WorkbookManagerInterface; use Box\Spout\Writer\Common\Manager\WorkbookManagerInterface;
@ -165,10 +165,10 @@ abstract class WriterMultiSheetsAbstract extends WriterAbstract
* with the creation of new worksheets if one worksheet has reached its maximum capicity. * with the creation of new worksheets if one worksheet has reached its maximum capicity.
* *
* @param Row $row * @param Row $row
* @return void
* @throws WriterNotOpenedException If the book is not created yet * @throws WriterNotOpenedException If the book is not created yet
* @throws \Box\Spout\Common\Exception\IOException If unable to write data * @throws \Box\Spout\Common\Exception\IOException If unable to write data
* @return void * @return void
* @return void
*/ */
protected function addRowToWriter(Row $row) protected function addRowToWriter(Row $row)
{ {

View File

@ -9,8 +9,8 @@ use Box\Spout\Common\Manager\OptionsManagerInterface;
use Box\Spout\Writer\Common\Creator\EntityFactory; use Box\Spout\Writer\Common\Creator\EntityFactory;
use Box\Spout\Writer\Common\Entity\Cell; use Box\Spout\Writer\Common\Entity\Cell;
use Box\Spout\Writer\Common\Entity\Options; use Box\Spout\Writer\Common\Entity\Options;
use Box\Spout\Writer\Common\Entity\Style\Style;
use Box\Spout\Writer\Common\Entity\Row; use Box\Spout\Writer\Common\Entity\Row;
use Box\Spout\Writer\Common\Entity\Style\Style;
use Box\Spout\Writer\Common\Entity\Worksheet; use Box\Spout\Writer\Common\Entity\Worksheet;
use Box\Spout\Writer\Common\Helper\CellHelper; use Box\Spout\Writer\Common\Helper\CellHelper;
use Box\Spout\Writer\Common\Manager\WorksheetManagerInterface; use Box\Spout\Writer\Common\Manager\WorksheetManagerInterface;
@ -124,10 +124,10 @@ EOD;
* *
* @param Worksheet $worksheet The worksheet to add the row to * @param Worksheet $worksheet The worksheet to add the row to
* @param Row $row The row to be added * @param Row $row The row to be added
* @return void
* @throws IOException If the data cannot be written * @throws IOException If the data cannot be written
* @throws InvalidArgumentException If a cell value's type is not supported * @throws InvalidArgumentException If a cell value's type is not supported
* @return void * @return void
* @return void
*/ */
public function addRow(Worksheet $worksheet, Row $row) public function addRow(Worksheet $worksheet, Row $row)
{ {
@ -142,11 +142,11 @@ EOD;
* Adds non empty row to the worksheet. * Adds non empty row to the worksheet.
* *
* @param Row $row The row to be written * @param Row $row The row to be written
* @return void
*
* @throws \Box\Spout\Common\Exception\IOException If the data cannot be written * @throws \Box\Spout\Common\Exception\IOException If the data cannot be written
* @throws \Box\Spout\Common\Exception\InvalidArgumentException If a cell value's type is not supported * @throws \Box\Spout\Common\Exception\InvalidArgumentException If a cell value's type is not supported
* @return void * @return void
*
* @return void
*/ */
private function addNonEmptyRow(Worksheet $worksheet, Row $row) private function addNonEmptyRow(Worksheet $worksheet, Row $row)
{ {

View File

@ -6,7 +6,6 @@ use Box\Spout\Common\Helper\EncodingHelper;
use Box\Spout\Common\Type; use Box\Spout\Common\Type;
use Box\Spout\TestUsingResource; use Box\Spout\TestUsingResource;
use Box\Spout\Writer\Common\Creator\EntityFactory; use Box\Spout\Writer\Common\Creator\EntityFactory;
use Box\Spout\Writer\Common\Creator\ManagerFactory;
use Box\Spout\Writer\Common\Entity\Cell; use Box\Spout\Writer\Common\Entity\Cell;
use Box\Spout\Writer\WriterFactory; use Box\Spout\Writer\WriterFactory;
@ -30,7 +29,7 @@ class WriterTest extends \PHPUnit_Framework_TestCase
@$writer->openToFile($filePath); @$writer->openToFile($filePath);
$row = EntityFactory::createRow([ $row = EntityFactory::createRow([
new Cell('csv--11'), new Cell('csv--11'),
new Cell('csv--12') new Cell('csv--12'),
]); ]);
$writer->addRow($row); $writer->addRow($row);
$writer->close(); $writer->close();
@ -44,7 +43,7 @@ class WriterTest extends \PHPUnit_Framework_TestCase
$writer = WriterFactory::create(Type::CSV); $writer = WriterFactory::create(Type::CSV);
$row = EntityFactory::createRow([ $row = EntityFactory::createRow([
new Cell('csv--11'), new Cell('csv--11'),
new Cell('csv--12') new Cell('csv--12'),
]); ]);
$writer->addRow($row); $writer->addRow($row);
$writer->close(); $writer->close();
@ -58,7 +57,7 @@ class WriterTest extends \PHPUnit_Framework_TestCase
$writer = WriterFactory::create(Type::CSV); $writer = WriterFactory::create(Type::CSV);
$row = EntityFactory::createRow([ $row = EntityFactory::createRow([
new Cell('csv--11'), new Cell('csv--11'),
new Cell('csv--12') new Cell('csv--12'),
]); ]);
$writer->addRows([$row]); $writer->addRows([$row]);
$writer->close(); $writer->close();
@ -229,6 +228,7 @@ class WriterTest extends \PHPUnit_Framework_TestCase
$row = EntityFactory::createRow(array_map(function ($value) { $row = EntityFactory::createRow(array_map(function ($value) {
return new Cell($value); return new Cell($value);
}, $oneRow)); }, $oneRow));
return $row; return $row;
}, $allRows)); }, $allRows));
$writer->close(); $writer->close();

View File

@ -10,6 +10,7 @@ class CellTest extends TestCase
{ {
$styleMock = $this $styleMock = $this
->getMockBuilder('Box\Spout\Writer\Common\Entity\Style\Style'); ->getMockBuilder('Box\Spout\Writer\Common\Entity\Style\Style');
return $styleMock; return $styleMock;
} }

View File

@ -10,6 +10,7 @@ class RowTest extends TestCase
{ {
$styleMock = $this $styleMock = $this
->getMockBuilder('Box\Spout\Writer\Common\Entity\Style\Style'); ->getMockBuilder('Box\Spout\Writer\Common\Entity\Style\Style');
return $styleMock; return $styleMock;
} }
@ -18,6 +19,7 @@ class RowTest extends TestCase
$cellMock = $this $cellMock = $this
->getMockBuilder('Box\Spout\Writer\Common\Entity\Cell') ->getMockBuilder('Box\Spout\Writer\Common\Entity\Cell')
->disableOriginalConstructor(); ->disableOriginalConstructor();
return $cellMock; return $cellMock;
} }
@ -26,6 +28,7 @@ class RowTest extends TestCase
$rowManagerMock = $this $rowManagerMock = $this
->getMockBuilder('Box\Spout\Writer\Common\Manager\RowManager') ->getMockBuilder('Box\Spout\Writer\Common\Manager\RowManager')
->disableOriginalConstructor(); ->disableOriginalConstructor();
return $rowManagerMock; return $rowManagerMock;
} }
@ -33,7 +36,8 @@ class RowTest extends TestCase
{ {
$this->assertInstanceOf( $this->assertInstanceOf(
'Box\Spout\Writer\Common\Entity\Row', 'Box\Spout\Writer\Common\Entity\Row',
new Row([], new Row(
[],
null, null,
$this->rowManagerMock()->getMock() $this->rowManagerMock()->getMock()
) )

View File

@ -27,15 +27,14 @@ class RowManagerTest extends TestCase
$this->assertTrue($this->rowManager->isEmpty($row)); $this->assertTrue($this->rowManager->isEmpty($row));
$row = new Row([ $row = new Row([
new Cell('') new Cell(''),
], null, $this->rowManager); ], null, $this->rowManager);
$this->assertTrue($this->rowManager->isEmpty($row)); $this->assertTrue($this->rowManager->isEmpty($row));
$row = new Row([ $row = new Row([
new Cell(''), new Cell(''),
new Cell(''), new Cell(''),
new Cell('Okay') new Cell('Okay'),
], null, $this->rowManager); ], null, $this->rowManager);
$this->assertFalse($this->rowManager->isEmpty($row)); $this->assertFalse($this->rowManager->isEmpty($row));
} }

View File

@ -5,7 +5,6 @@ namespace Box\Spout\Writer\ODS;
use Box\Spout\Common\Type; use Box\Spout\Common\Type;
use Box\Spout\TestUsingResource; use Box\Spout\TestUsingResource;
use Box\Spout\Writer\Common\Creator\EntityFactory; use Box\Spout\Writer\Common\Creator\EntityFactory;
use Box\Spout\Writer\Common\Creator\ManagerFactory;
use Box\Spout\Writer\Common\Entity\Cell; use Box\Spout\Writer\Common\Entity\Cell;
use Box\Spout\Writer\Common\Entity\Sheet; use Box\Spout\Writer\Common\Entity\Sheet;
use Box\Spout\Writer\WriterFactory; use Box\Spout\Writer\WriterFactory;

View File

@ -53,7 +53,7 @@ class WriterTest extends \PHPUnit_Framework_TestCase
$writer = WriterFactory::create(Type::ODS); $writer = WriterFactory::create(Type::ODS);
$row = $this->entityFactory->createRow([ $row = $this->entityFactory->createRow([
new Cell('csv--11'), new Cell('csv--11'),
new Cell('csv--12') new Cell('csv--12'),
]); ]);
$writer->addRow($row); $writer->addRow($row);
} }
@ -66,7 +66,7 @@ class WriterTest extends \PHPUnit_Framework_TestCase
$writer = WriterFactory::create(Type::ODS); $writer = WriterFactory::create(Type::ODS);
$row = $this->entityFactory->createRow([ $row = $this->entityFactory->createRow([
new Cell('csv--11'), new Cell('csv--11'),
new Cell('csv--12') new Cell('csv--12'),
]); ]);
$writer->addRows([$row]); $writer->addRows([$row]);
} }
@ -140,7 +140,6 @@ class WriterTest extends \PHPUnit_Framework_TestCase
$writer->addRows($dataRows); $writer->addRows($dataRows);
$this->fail('Exception should have been thrown'); $this->fail('Exception should have been thrown');
} catch (SpoutException $e) { } catch (SpoutException $e) {
$this->assertFalse(file_exists($fileName), 'Output file should have been deleted'); $this->assertFalse(file_exists($fileName), 'Output file should have been deleted');
$numFiles = iterator_count(new \FilesystemIterator($tempFolderPath, \FilesystemIterator::SKIP_DOTS)); $numFiles = iterator_count(new \FilesystemIterator($tempFolderPath, \FilesystemIterator::SKIP_DOTS));
@ -343,6 +342,7 @@ class WriterTest extends \PHPUnit_Framework_TestCase
$row = $this->entityFactory->createRow(array_map(function ($value) { $row = $this->entityFactory->createRow(array_map(function ($value) {
return new Cell($value); return new Cell($value);
}, $oneRow)); }, $oneRow));
return $row; return $row;
}, $allRows); }, $allRows);
}; };
@ -563,6 +563,7 @@ class WriterTest extends \PHPUnit_Framework_TestCase
return $value; return $value;
} }
}, $oneRow)); }, $oneRow));
return $row; return $row;
}, $allRows)); }, $allRows));
$writer->close(); $writer->close();
@ -591,6 +592,7 @@ class WriterTest extends \PHPUnit_Framework_TestCase
$row = $this->entityFactory->createRow(array_map(function ($value) { $row = $this->entityFactory->createRow(array_map(function ($value) {
return new Cell($value); return new Cell($value);
}, $oneRow)); }, $oneRow));
return $row; return $row;
}, $allRows)); }, $allRows));
@ -600,6 +602,7 @@ class WriterTest extends \PHPUnit_Framework_TestCase
$row = $this->entityFactory->createRow(array_map(function ($value) { $row = $this->entityFactory->createRow(array_map(function ($value) {
return new Cell($value); return new Cell($value);
}, $oneRow)); }, $oneRow));
return $row; return $row;
}, $allRows)); }, $allRows));
} }

View File

@ -6,10 +6,10 @@ use Box\Spout\Common\Type;
use Box\Spout\Reader\Wrapper\XMLReader; use Box\Spout\Reader\Wrapper\XMLReader;
use Box\Spout\TestUsingResource; use Box\Spout\TestUsingResource;
use Box\Spout\Writer\Common\Creator\EntityFactory; use Box\Spout\Writer\Common\Creator\EntityFactory;
use Box\Spout\Writer\Common\Entity\Cell;
use Box\Spout\Writer\Common\Entity\Style\Border;
use Box\Spout\Writer\Common\Creator\Style\BorderBuilder; use Box\Spout\Writer\Common\Creator\Style\BorderBuilder;
use Box\Spout\Writer\Common\Creator\Style\StyleBuilder; use Box\Spout\Writer\Common\Creator\Style\StyleBuilder;
use Box\Spout\Writer\Common\Entity\Cell;
use Box\Spout\Writer\Common\Entity\Style\Border;
use Box\Spout\Writer\Common\Entity\Style\Color; use Box\Spout\Writer\Common\Entity\Style\Color;
use Box\Spout\Writer\Common\Entity\Style\Style; use Box\Spout\Writer\Common\Entity\Style\Style;
use Box\Spout\Writer\WriterFactory; use Box\Spout\Writer\WriterFactory;
@ -102,7 +102,6 @@ class WriterWithStyleTest extends \PHPUnit_Framework_TestCase
*/ */
public function testAddRowsWithStyleShouldThrowExceptionIfInvalidStyleGiven($style) public function testAddRowsWithStyleShouldThrowExceptionIfInvalidStyleGiven($style)
{ {
if (version_compare(PHP_VERSION, '7.0.0') >= 0) { if (version_compare(PHP_VERSION, '7.0.0') >= 0) {
$this->expectException(\TypeError::class); $this->expectException(\TypeError::class);
} else { } else {
@ -357,7 +356,7 @@ class WriterWithStyleTest extends \PHPUnit_Framework_TestCase
{ {
$fileName = 'test_set_default_row_style.ods'; $fileName = 'test_set_default_row_style.ods';
$row = EntityFactory::createRow([ $row = EntityFactory::createRow([
new Cell('ods--11') new Cell('ods--11'),
]); ]);
$dataRows = [$row]; $dataRows = [$row];
@ -383,6 +382,7 @@ class WriterWithStyleTest extends \PHPUnit_Framework_TestCase
$row = EntityFactory::createRow(array_map(function ($value) { $row = EntityFactory::createRow(array_map(function ($value) {
return new Cell($value); return new Cell($value);
}, $oneRow), $style); }, $oneRow), $style);
return $row; return $row;
}, $allRows); }, $allRows);
}; };

View File

@ -5,7 +5,6 @@ namespace Box\Spout\Writer\XLSX;
use Box\Spout\Common\Type; use Box\Spout\Common\Type;
use Box\Spout\TestUsingResource; use Box\Spout\TestUsingResource;
use Box\Spout\Writer\Common\Creator\EntityFactory; use Box\Spout\Writer\Common\Creator\EntityFactory;
use Box\Spout\Writer\Common\Creator\ManagerFactory;
use Box\Spout\Writer\Common\Entity\Cell; use Box\Spout\Writer\Common\Entity\Cell;
use Box\Spout\Writer\Common\Entity\Sheet; use Box\Spout\Writer\Common\Entity\Sheet;
use Box\Spout\Writer\WriterFactory; use Box\Spout\Writer\WriterFactory;

View File

@ -53,7 +53,7 @@ class WriterTest extends \PHPUnit_Framework_TestCase
$row = $this->entityFactory->createRow([ $row = $this->entityFactory->createRow([
new Cell('xlsx--11'), new Cell('xlsx--11'),
new Cell('xlsx--12') new Cell('xlsx--12'),
]); ]);
$writer->addRow($row); $writer->addRow($row);
} }
@ -66,7 +66,7 @@ class WriterTest extends \PHPUnit_Framework_TestCase
$writer = WriterFactory::create(Type::XLSX); $writer = WriterFactory::create(Type::XLSX);
$row = $this->entityFactory->createRow([ $row = $this->entityFactory->createRow([
new Cell('xlsx--11'), new Cell('xlsx--11'),
new Cell('xlsx--12') new Cell('xlsx--12'),
]); ]);
$writer->addRows([$row]); $writer->addRows([$row]);
} }
@ -386,12 +386,12 @@ class WriterTest extends \PHPUnit_Framework_TestCase
*/ */
public function testAddRowShouldWriteGivenDataToTheCorrectSheet() public function testAddRowShouldWriteGivenDataToTheCorrectSheet()
{ {
$arrayToRows = function (array $allRows) { $arrayToRows = function (array $allRows) {
return array_map(function ($oneRow) { return array_map(function ($oneRow) {
$row = $this->entityFactory->createRow(array_map(function ($value) { $row = $this->entityFactory->createRow(array_map(function ($value) {
return new Cell($value); return new Cell($value);
}, $oneRow)); }, $oneRow));
return $row; return $row;
}, $allRows); }, $allRows);
}; };
@ -621,6 +621,7 @@ class WriterTest extends \PHPUnit_Framework_TestCase
return $value; return $value;
} }
}, $oneRow)); }, $oneRow));
return $row; return $row;
}, $allRows)); }, $allRows));
$writer->close(); $writer->close();
@ -651,6 +652,7 @@ class WriterTest extends \PHPUnit_Framework_TestCase
$row = $this->entityFactory->createRow(array_map(function ($value) { $row = $this->entityFactory->createRow(array_map(function ($value) {
return new Cell($value); return new Cell($value);
}, $oneRow)); }, $oneRow));
return $row; return $row;
}, $allRows)); }, $allRows));
@ -660,6 +662,7 @@ class WriterTest extends \PHPUnit_Framework_TestCase
$row = $this->entityFactory->createRow(array_map(function ($value) { $row = $this->entityFactory->createRow(array_map(function ($value) {
return new Cell($value); return new Cell($value);
}, $oneRow)); }, $oneRow));
return $row; return $row;
}, $allRows)); }, $allRows));
} }

View File

@ -42,7 +42,7 @@ class WriterWithStyleTest extends \PHPUnit_Framework_TestCase
$writer = WriterFactory::create(Type::XLSX); $writer = WriterFactory::create(Type::XLSX);
$row = EntityFactory::createRow([ $row = EntityFactory::createRow([
new Cell('xlsx--11'), new Cell('xlsx--11'),
new Cell('xlsx--12') new Cell('xlsx--12'),
], $this->defaultStyle); ], $this->defaultStyle);
$writer->addRow($row); $writer->addRow($row);
} }
@ -55,7 +55,7 @@ class WriterWithStyleTest extends \PHPUnit_Framework_TestCase
$writer = WriterFactory::create(Type::XLSX); $writer = WriterFactory::create(Type::XLSX);
$row = EntityFactory::createRow([ $row = EntityFactory::createRow([
new Cell('xlsx--11'), new Cell('xlsx--11'),
new Cell('xlsx--12') new Cell('xlsx--12'),
], $this->defaultStyle); ], $this->defaultStyle);
$writer->addRows([$row]); $writer->addRows([$row]);
} }
@ -92,7 +92,7 @@ class WriterWithStyleTest extends \PHPUnit_Framework_TestCase
$writer->openToFile($resourcePath); $writer->openToFile($resourcePath);
$row = EntityFactory::createRow([ $row = EntityFactory::createRow([
new Cell('xlsx--11'), new Cell('xlsx--11'),
new Cell('xlsx--12') new Cell('xlsx--12'),
], $style); ], $style);
$writer->addRow($row); $writer->addRow($row);
} }
@ -118,7 +118,7 @@ class WriterWithStyleTest extends \PHPUnit_Framework_TestCase
$writer->openToFile($resourcePath); $writer->openToFile($resourcePath);
$row = EntityFactory::createRow([ $row = EntityFactory::createRow([
new Cell('xlsx--11'), new Cell('xlsx--11'),
new Cell('xlsx--12') new Cell('xlsx--12'),
], $style); ], $style);
$writer->addRows([$row]); $writer->addRows([$row]);
} }
@ -458,7 +458,7 @@ class WriterWithStyleTest extends \PHPUnit_Framework_TestCase
$fileName = 'test_set_default_row_style.xlsx'; $fileName = 'test_set_default_row_style.xlsx';
$row = EntityFactory::createRow([ $row = EntityFactory::createRow([
new Cell('xlsx--11') new Cell('xlsx--11'),
]); ]);
$dataRows = [$row]; $dataRows = [$row];
@ -552,17 +552,16 @@ class WriterWithStyleTest extends \PHPUnit_Framework_TestCase
*/ */
private function writeToXLSXFile($allRows, $fileName, $style) private function writeToXLSXFile($allRows, $fileName, $style)
{ {
$arrayToRows = function (array $allRows) use ($style) { $arrayToRows = function (array $allRows) use ($style) {
return array_map(function ($oneRow) use ($style) { return array_map(function ($oneRow) use ($style) {
$row = EntityFactory::createRow(array_map(function ($value) { $row = EntityFactory::createRow(array_map(function ($value) {
return new Cell($value); return new Cell($value);
}, $oneRow), $style); }, $oneRow), $style);
return $row; return $row;
}, $allRows); }, $allRows);
}; };
$this->createGeneratedFolderIfNeeded($fileName); $this->createGeneratedFolderIfNeeded($fileName);
$resourcePath = $this->getGeneratedResourcePath($fileName); $resourcePath = $this->getGeneratedResourcePath($fileName);
@ -585,8 +584,6 @@ class WriterWithStyleTest extends \PHPUnit_Framework_TestCase
*/ */
private function writeToXLSXFileWithDefaultStyle($allRows, $fileName, $defaultStyle) private function writeToXLSXFileWithDefaultStyle($allRows, $fileName, $defaultStyle)
{ {
$this->createGeneratedFolderIfNeeded($fileName); $this->createGeneratedFolderIfNeeded($fileName);
$resourcePath = $this->getGeneratedResourcePath($fileName); $resourcePath = $this->getGeneratedResourcePath($fileName);