php-cs-fixer fix
This commit is contained in:
parent
8739bce698
commit
823fbdb43f
@ -83,8 +83,8 @@ class Writer extends WriterAbstract
|
||||
*
|
||||
* @param Row $row The row containing cells and styles
|
||||
*
|
||||
* @return void
|
||||
* @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.
|
||||
*/
|
||||
protected function addRowToWriter(Row $row)
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
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\Row;
|
||||
use Box\Spout\Writer\Common\Entity\Sheet;
|
||||
use Box\Spout\Writer\Common\Entity\Style\Style;
|
||||
use Box\Spout\Writer\Common\Entity\Workbook;
|
||||
@ -73,6 +73,7 @@ class EntityFactory
|
||||
{
|
||||
$styleMerger = new StyleMerger();
|
||||
$rowManager = new RowManager($styleMerger);
|
||||
|
||||
return new Row($cells, $style, $rowManager);
|
||||
}
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ class Cell
|
||||
* The cell style
|
||||
* @var Style|null
|
||||
*/
|
||||
protected $style = null;
|
||||
protected $style;
|
||||
|
||||
/**
|
||||
* @var StyleMerger
|
||||
@ -110,6 +110,7 @@ class Cell
|
||||
if (!isset($this->style)) {
|
||||
$this->setStyle(new Style());
|
||||
}
|
||||
|
||||
return $this->style;
|
||||
}
|
||||
|
||||
@ -212,6 +213,7 @@ class Cell
|
||||
}
|
||||
$mergedStyle = $this->styleMerger->merge($this->getStyle(), $style);
|
||||
$this->setStyle($mergedStyle);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ namespace Box\Spout\Writer\Common\Entity;
|
||||
|
||||
use Box\Spout\Writer\Common\Entity\Style\Style;
|
||||
use Box\Spout\Writer\Common\Manager\RowManager;
|
||||
use Box\Spout\Writer\Common\Manager\Style\StyleMerger;
|
||||
|
||||
class Row
|
||||
{
|
||||
@ -16,9 +15,9 @@ class Row
|
||||
|
||||
/**
|
||||
* The row style
|
||||
* @var null|Style
|
||||
* @var Style|null
|
||||
*/
|
||||
protected $style = null;
|
||||
protected $style;
|
||||
|
||||
/**
|
||||
* Thw row manager
|
||||
@ -59,6 +58,7 @@ class Row
|
||||
foreach ($cells as $cell) {
|
||||
$this->addCell($cell);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -70,6 +70,7 @@ class Row
|
||||
if (!isset($this->style)) {
|
||||
$this->setStyle(new Style());
|
||||
}
|
||||
|
||||
return $this->style;
|
||||
}
|
||||
|
||||
@ -80,6 +81,7 @@ class Row
|
||||
public function setStyle($style)
|
||||
{
|
||||
$this->style = $style;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -90,6 +92,7 @@ class Row
|
||||
public function applyStyle(Style $style = null)
|
||||
{
|
||||
$this->rowManager->applyStyle($this, $style);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -100,6 +103,7 @@ class Row
|
||||
public function addCell(Cell $cell)
|
||||
{
|
||||
$this->cells[] = $cell;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -34,4 +34,4 @@ class CellManager
|
||||
$mergedStyle = $this->styleMerger->merge($cell->getStyle(), $style);
|
||||
$cell->setStyle($mergedStyle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -42,6 +42,7 @@ class RowManager
|
||||
public function isEmpty(Row $row)
|
||||
{
|
||||
$cells = $row->getCells();
|
||||
|
||||
return count($cells) === 0 || (count($cells) === 1 && $cells[0]->isEmpty());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -55,6 +55,7 @@ class StyleManager implements StyleManagerInterface
|
||||
public function applyExtraStylesIfNeeded(Cell $cell)
|
||||
{
|
||||
$updatedStyle = $this->applyWrapTextIfCellContainsNewLine($cell);
|
||||
|
||||
return $updatedStyle;
|
||||
}
|
||||
|
||||
@ -79,6 +80,7 @@ class StyleManager implements StyleManagerInterface
|
||||
if ($cell->isString() && strpos($cell->getValue(), "\n") !== false) {
|
||||
$cell->getStyle()->setShouldWrapText();
|
||||
}
|
||||
|
||||
return $cell->getStyle();
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ namespace Box\Spout\Writer\Common\Manager\Style;
|
||||
use Box\Spout\Writer\Common\Entity\Cell;
|
||||
use Box\Spout\Writer\Common\Entity\Style\Style;
|
||||
|
||||
|
||||
/**
|
||||
* Interface StyleHManagernterface
|
||||
*/
|
||||
|
@ -203,10 +203,10 @@ abstract class WorkbookManagerAbstract implements WorkbookManagerInterface
|
||||
* with the creation of new worksheets if one worksheet has reached its maximum capicity.
|
||||
*
|
||||
* @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 WriterException If unable to write data
|
||||
* @return void
|
||||
* @return void
|
||||
*/
|
||||
public function addRowToCurrentWorksheet(Row $row)
|
||||
{
|
||||
@ -243,9 +243,9 @@ abstract class WorkbookManagerAbstract implements WorkbookManagerInterface
|
||||
*
|
||||
* @param Worksheet $worksheet Worksheet to write the row to
|
||||
* @param Row $row The row to be added
|
||||
* @return void
|
||||
* @throws WriterException If unable to write data
|
||||
* @return void
|
||||
* @return void
|
||||
*/
|
||||
private function addRowToWorksheet(Worksheet $worksheet, Row $row)
|
||||
{
|
||||
|
@ -3,9 +3,8 @@
|
||||
namespace Box\Spout\Writer\Common\Manager;
|
||||
|
||||
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\Sheet;
|
||||
use Box\Spout\Writer\Common\Entity\Workbook;
|
||||
use Box\Spout\Writer\Common\Entity\Worksheet;
|
||||
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.
|
||||
*
|
||||
* @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 WriterException If unable to write data
|
||||
* @return void
|
||||
* @return void
|
||||
*/
|
||||
public function addRowToCurrentWorksheet(Row $row);
|
||||
|
||||
/**
|
||||
* Closes the workbook and all its associated sheets.
|
||||
* All the necessary files are written to disk and zipped together to create the final file.
|
||||
|
@ -3,7 +3,6 @@
|
||||
namespace Box\Spout\Writer\Common\Manager;
|
||||
|
||||
use Box\Spout\Writer\Common\Entity\Row;
|
||||
use Box\Spout\Writer\Common\Entity\Style\Style;
|
||||
use Box\Spout\Writer\Common\Entity\Worksheet;
|
||||
|
||||
/**
|
||||
@ -17,10 +16,10 @@ interface WorksheetManagerInterface
|
||||
*
|
||||
* @param Worksheet $worksheet The worksheet to add the row to
|
||||
* @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\InvalidArgumentException If a cell value's type is not supported
|
||||
* @return void
|
||||
* @return void
|
||||
*/
|
||||
public function addRow(Worksheet $worksheet, Row $row);
|
||||
|
||||
|
@ -68,8 +68,8 @@ class ManagerFactory implements ManagerFactoryInterface
|
||||
$stringsEscaper = $this->helperFactory->createStringsEscaper();
|
||||
$stringsHelper = $this->helperFactory->createStringHelper();
|
||||
|
||||
|
||||
return new WorksheetManager($styleManager, $stringsEscaper, $stringsHelper);
|
||||
|
||||
return new WorksheetManager($stringsEscaper, $stringsHelper, $this->entityFactory);
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,6 @@ use Box\Spout\Common\Exception\InvalidArgumentException;
|
||||
use Box\Spout\Common\Exception\IOException;
|
||||
use Box\Spout\Common\Helper\Escaper\ODS as ODSEscaper;
|
||||
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\Row;
|
||||
use Box\Spout\Writer\Common\Entity\Worksheet;
|
||||
@ -37,8 +36,8 @@ class WorksheetManager implements WorksheetManagerInterface
|
||||
public function __construct(
|
||||
StyleManager $styleManager,
|
||||
ODSEscaper $stringsEscaper,
|
||||
StringHelper $stringHelper)
|
||||
{
|
||||
StringHelper $stringHelper
|
||||
) {
|
||||
$this->stringsEscaper = $stringsEscaper;
|
||||
$this->stringHelper = $stringHelper;
|
||||
$this->styleManager = $styleManager;
|
||||
@ -96,15 +95,14 @@ class WorksheetManager implements WorksheetManagerInterface
|
||||
*
|
||||
* @param Worksheet $worksheet The worksheet to add the row to
|
||||
* @param Row $row The row to be added
|
||||
* @return void
|
||||
*
|
||||
* @throws IOException If the data cannot be written
|
||||
* @throws InvalidArgumentException If a cell value's type is not supported
|
||||
* @return void
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addRow(Worksheet $worksheet, Row $row)
|
||||
{
|
||||
|
||||
$cells = $row->getCells();
|
||||
$cellsCount = count($cells);
|
||||
|
||||
@ -114,15 +112,13 @@ class WorksheetManager implements WorksheetManagerInterface
|
||||
$nextCellIndex = 1;
|
||||
|
||||
for ($i = 0; $i < $cellsCount; $i++) {
|
||||
|
||||
/** @var Cell $cell */
|
||||
$cell = $cells[$currentCellIndex];
|
||||
/** @var Cell|null $nextCell */
|
||||
$nextCell = isset($cells[$nextCellIndex]) ? $cells[$nextCellIndex] : null;
|
||||
|
||||
// @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
|
||||
$cell->applyStyle($row->getStyle());
|
||||
$this->styleManager->applyExtraStylesIfNeeded($cell);
|
||||
|
@ -7,9 +7,9 @@ use Box\Spout\Common\Exception\InvalidArgumentException;
|
||||
use Box\Spout\Common\Exception\IOException;
|
||||
use Box\Spout\Common\Exception\SpoutException;
|
||||
use Box\Spout\Common\Helper\GlobalFunctionsHelper;
|
||||
use Box\Spout\Common\Manager\OptionsManagerInterface;
|
||||
use Box\Spout\Writer\Common\Creator\EntityFactory;
|
||||
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\Row;
|
||||
use Box\Spout\Writer\Common\Entity\Style\Style;
|
||||
@ -98,11 +98,12 @@ abstract class WriterAbstract implements WriterInterface
|
||||
public function setDefaultRowStyle($defaultStyle)
|
||||
{
|
||||
$this->optionsManager->setOption(Options::DEFAULT_ROW_STYLE, $defaultStyle);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function openToFile($outputFilePath)
|
||||
{
|
||||
@ -118,7 +119,7 @@ abstract class WriterAbstract implements WriterInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function openToBrowser($outputFileName)
|
||||
{
|
||||
@ -181,7 +182,7 @@ abstract class WriterAbstract implements WriterInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function addRow(Row $row)
|
||||
{
|
||||
@ -201,11 +202,12 @@ abstract class WriterAbstract implements WriterInterface
|
||||
} else {
|
||||
throw new WriterNotOpenedException('The writer needs to be opened before adding row.');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function withRow(\Closure $callback)
|
||||
{
|
||||
@ -213,19 +215,19 @@ abstract class WriterAbstract implements WriterInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function addRows(array $dataRows)
|
||||
{
|
||||
foreach ($dataRows as $dataRow) {
|
||||
|
||||
if(!$dataRow instanceof Row) {
|
||||
if (!$dataRow instanceof Row) {
|
||||
$this->closeAndAttemptToCleanupAllFiles();
|
||||
throw new InvalidArgumentException();
|
||||
}
|
||||
|
||||
$this->addRow($dataRow);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -240,6 +242,7 @@ abstract class WriterAbstract implements WriterInterface
|
||||
if ($value instanceof Cell) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
return new Cell($value);
|
||||
}, $dataRow));
|
||||
|
||||
@ -259,7 +262,7 @@ abstract class WriterAbstract implements WriterInterface
|
||||
private function applyDefaultRowStyle(Row $row)
|
||||
{
|
||||
$defaultRowStyle = $this->optionsManager->getOption(Options::DEFAULT_ROW_STYLE);
|
||||
if (null === $defaultRowStyle) {
|
||||
if ($defaultRowStyle === null) {
|
||||
return $this;
|
||||
}
|
||||
$mergedStyle = $this->styleMerger->merge($row->getStyle(), $defaultRowStyle);
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
namespace Box\Spout\Writer;
|
||||
|
||||
use Box\Spout\Common\Exception\IOException;
|
||||
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.
|
||||
*
|
||||
* @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\Writer\Exception\WriterNotOpenedException If the writer has not been opened yet
|
||||
* @throws \Box\Spout\Common\Exception\IOException If unable to write data
|
||||
* @return WriterInterface
|
||||
* @return WriterInterface
|
||||
*/
|
||||
public function addRows(array $rows);
|
||||
|
||||
|
@ -7,8 +7,8 @@ use Box\Spout\Common\Helper\GlobalFunctionsHelper;
|
||||
use Box\Spout\Common\Manager\OptionsManagerInterface;
|
||||
use Box\Spout\Writer\Common\Creator\ManagerFactoryInterface;
|
||||
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\Sheet;
|
||||
use Box\Spout\Writer\Common\Entity\Worksheet;
|
||||
use Box\Spout\Writer\Common\Manager\Style\StyleMerger;
|
||||
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.
|
||||
*
|
||||
* @param Row $row
|
||||
* @return void
|
||||
* @throws WriterNotOpenedException If the book is not created yet
|
||||
* @throws \Box\Spout\Common\Exception\IOException If unable to write data
|
||||
* @return void
|
||||
* @return void
|
||||
*/
|
||||
protected function addRowToWriter(Row $row)
|
||||
{
|
||||
|
@ -9,8 +9,8 @@ use Box\Spout\Common\Manager\OptionsManagerInterface;
|
||||
use Box\Spout\Writer\Common\Creator\EntityFactory;
|
||||
use Box\Spout\Writer\Common\Entity\Cell;
|
||||
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\Style\Style;
|
||||
use Box\Spout\Writer\Common\Entity\Worksheet;
|
||||
use Box\Spout\Writer\Common\Helper\CellHelper;
|
||||
use Box\Spout\Writer\Common\Manager\WorksheetManagerInterface;
|
||||
@ -124,10 +124,10 @@ EOD;
|
||||
*
|
||||
* @param Worksheet $worksheet The worksheet to add the row to
|
||||
* @param Row $row The row to be added
|
||||
* @return void
|
||||
* @throws IOException If the data cannot be written
|
||||
* @throws InvalidArgumentException If a cell value's type is not supported
|
||||
* @return void
|
||||
* @return void
|
||||
*/
|
||||
public function addRow(Worksheet $worksheet, Row $row)
|
||||
{
|
||||
@ -142,11 +142,11 @@ EOD;
|
||||
* Adds non empty row to the worksheet.
|
||||
*
|
||||
* @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\InvalidArgumentException If a cell value's type is not supported
|
||||
* @return void
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function addNonEmptyRow(Worksheet $worksheet, Row $row)
|
||||
{
|
||||
@ -158,7 +158,7 @@ EOD;
|
||||
|
||||
// @TODO refactoring: move this to its own method
|
||||
/** @var Cell $cell */
|
||||
foreach($row->getCells() as $cell) {
|
||||
foreach ($row->getCells() as $cell) {
|
||||
// Apply styles - the row style is merged at this point
|
||||
$cell->applyStyle($row->getStyle());
|
||||
$this->styleManager->applyExtraStylesIfNeeded($cell);
|
||||
|
@ -6,7 +6,6 @@ use Box\Spout\Common\Helper\EncodingHelper;
|
||||
use Box\Spout\Common\Type;
|
||||
use Box\Spout\TestUsingResource;
|
||||
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\WriterFactory;
|
||||
|
||||
@ -30,7 +29,7 @@ class WriterTest extends \PHPUnit_Framework_TestCase
|
||||
@$writer->openToFile($filePath);
|
||||
$row = EntityFactory::createRow([
|
||||
new Cell('csv--11'),
|
||||
new Cell('csv--12')
|
||||
new Cell('csv--12'),
|
||||
]);
|
||||
$writer->addRow($row);
|
||||
$writer->close();
|
||||
@ -44,7 +43,7 @@ class WriterTest extends \PHPUnit_Framework_TestCase
|
||||
$writer = WriterFactory::create(Type::CSV);
|
||||
$row = EntityFactory::createRow([
|
||||
new Cell('csv--11'),
|
||||
new Cell('csv--12')
|
||||
new Cell('csv--12'),
|
||||
]);
|
||||
$writer->addRow($row);
|
||||
$writer->close();
|
||||
@ -58,7 +57,7 @@ class WriterTest extends \PHPUnit_Framework_TestCase
|
||||
$writer = WriterFactory::create(Type::CSV);
|
||||
$row = EntityFactory::createRow([
|
||||
new Cell('csv--11'),
|
||||
new Cell('csv--12')
|
||||
new Cell('csv--12'),
|
||||
]);
|
||||
$writer->addRows([$row]);
|
||||
$writer->close();
|
||||
@ -229,6 +228,7 @@ class WriterTest extends \PHPUnit_Framework_TestCase
|
||||
$row = EntityFactory::createRow(array_map(function ($value) {
|
||||
return new Cell($value);
|
||||
}, $oneRow));
|
||||
|
||||
return $row;
|
||||
}, $allRows));
|
||||
$writer->close();
|
||||
|
@ -10,6 +10,7 @@ class CellTest extends TestCase
|
||||
{
|
||||
$styleMock = $this
|
||||
->getMockBuilder('Box\Spout\Writer\Common\Entity\Style\Style');
|
||||
|
||||
return $styleMock;
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@ class RowTest extends TestCase
|
||||
{
|
||||
$styleMock = $this
|
||||
->getMockBuilder('Box\Spout\Writer\Common\Entity\Style\Style');
|
||||
|
||||
return $styleMock;
|
||||
}
|
||||
|
||||
@ -18,6 +19,7 @@ class RowTest extends TestCase
|
||||
$cellMock = $this
|
||||
->getMockBuilder('Box\Spout\Writer\Common\Entity\Cell')
|
||||
->disableOriginalConstructor();
|
||||
|
||||
return $cellMock;
|
||||
}
|
||||
|
||||
@ -26,6 +28,7 @@ class RowTest extends TestCase
|
||||
$rowManagerMock = $this
|
||||
->getMockBuilder('Box\Spout\Writer\Common\Manager\RowManager')
|
||||
->disableOriginalConstructor();
|
||||
|
||||
return $rowManagerMock;
|
||||
}
|
||||
|
||||
@ -33,7 +36,8 @@ class RowTest extends TestCase
|
||||
{
|
||||
$this->assertInstanceOf(
|
||||
'Box\Spout\Writer\Common\Entity\Row',
|
||||
new Row([],
|
||||
new Row(
|
||||
[],
|
||||
null,
|
||||
$this->rowManagerMock()->getMock()
|
||||
)
|
||||
|
@ -27,16 +27,15 @@ class RowManagerTest extends TestCase
|
||||
$this->assertTrue($this->rowManager->isEmpty($row));
|
||||
|
||||
$row = new Row([
|
||||
new Cell('')
|
||||
new Cell(''),
|
||||
], null, $this->rowManager);
|
||||
$this->assertTrue($this->rowManager->isEmpty($row));
|
||||
|
||||
|
||||
$row = new Row([
|
||||
new Cell(''),
|
||||
new Cell(''),
|
||||
new Cell('Okay')
|
||||
new Cell('Okay'),
|
||||
], null, $this->rowManager);
|
||||
$this->assertFalse($this->rowManager->isEmpty($row));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ namespace Box\Spout\Writer\ODS;
|
||||
use Box\Spout\Common\Type;
|
||||
use Box\Spout\TestUsingResource;
|
||||
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\Sheet;
|
||||
use Box\Spout\Writer\WriterFactory;
|
||||
|
@ -53,7 +53,7 @@ class WriterTest extends \PHPUnit_Framework_TestCase
|
||||
$writer = WriterFactory::create(Type::ODS);
|
||||
$row = $this->entityFactory->createRow([
|
||||
new Cell('csv--11'),
|
||||
new Cell('csv--12')
|
||||
new Cell('csv--12'),
|
||||
]);
|
||||
$writer->addRow($row);
|
||||
}
|
||||
@ -66,7 +66,7 @@ class WriterTest extends \PHPUnit_Framework_TestCase
|
||||
$writer = WriterFactory::create(Type::ODS);
|
||||
$row = $this->entityFactory->createRow([
|
||||
new Cell('csv--11'),
|
||||
new Cell('csv--12')
|
||||
new Cell('csv--12'),
|
||||
]);
|
||||
$writer->addRows([$row]);
|
||||
}
|
||||
@ -140,7 +140,6 @@ class WriterTest extends \PHPUnit_Framework_TestCase
|
||||
$writer->addRows($dataRows);
|
||||
$this->fail('Exception should have been thrown');
|
||||
} catch (SpoutException $e) {
|
||||
|
||||
$this->assertFalse(file_exists($fileName), 'Output file should have been deleted');
|
||||
|
||||
$numFiles = iterator_count(new \FilesystemIterator($tempFolderPath, \FilesystemIterator::SKIP_DOTS));
|
||||
@ -324,7 +323,7 @@ class WriterTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
if ($expectedNumTableCells === 1) {
|
||||
$tableCellNode = $tableCellNodes->item(0);
|
||||
$numColumnsRepeated = (int)($tableCellNode->getAttribute('table:number-columns-repeated'));
|
||||
$numColumnsRepeated = (int) ($tableCellNode->getAttribute('table:number-columns-repeated'));
|
||||
$this->assertEquals($expectedNumColumnsRepeated, $numColumnsRepeated);
|
||||
} else {
|
||||
foreach ($tableCellNodes as $tableCellNode) {
|
||||
@ -343,6 +342,7 @@ class WriterTest extends \PHPUnit_Framework_TestCase
|
||||
$row = $this->entityFactory->createRow(array_map(function ($value) {
|
||||
return new Cell($value);
|
||||
}, $oneRow));
|
||||
|
||||
return $row;
|
||||
}, $allRows);
|
||||
};
|
||||
@ -534,7 +534,7 @@ class WriterTest extends \PHPUnit_Framework_TestCase
|
||||
foreach ($dataRows as $dataRow) {
|
||||
/** @var Cell $cell */
|
||||
foreach ($dataRow as $cell) {
|
||||
$this->assertValueWasWritten($fileName, (string)$cell->getValue(), '');
|
||||
$this->assertValueWasWritten($fileName, (string) $cell->getValue(), '');
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -563,6 +563,7 @@ class WriterTest extends \PHPUnit_Framework_TestCase
|
||||
return $value;
|
||||
}
|
||||
}, $oneRow));
|
||||
|
||||
return $row;
|
||||
}, $allRows));
|
||||
$writer->close();
|
||||
@ -591,6 +592,7 @@ class WriterTest extends \PHPUnit_Framework_TestCase
|
||||
$row = $this->entityFactory->createRow(array_map(function ($value) {
|
||||
return new Cell($value);
|
||||
}, $oneRow));
|
||||
|
||||
return $row;
|
||||
}, $allRows));
|
||||
|
||||
@ -600,6 +602,7 @@ class WriterTest extends \PHPUnit_Framework_TestCase
|
||||
$row = $this->entityFactory->createRow(array_map(function ($value) {
|
||||
return new Cell($value);
|
||||
}, $oneRow));
|
||||
|
||||
return $row;
|
||||
}, $allRows));
|
||||
}
|
||||
|
@ -6,10 +6,10 @@ use Box\Spout\Common\Type;
|
||||
use Box\Spout\Reader\Wrapper\XMLReader;
|
||||
use Box\Spout\TestUsingResource;
|
||||
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\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\Style;
|
||||
use Box\Spout\Writer\WriterFactory;
|
||||
@ -102,7 +102,6 @@ class WriterWithStyleTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testAddRowsWithStyleShouldThrowExceptionIfInvalidStyleGiven($style)
|
||||
{
|
||||
|
||||
if (version_compare(PHP_VERSION, '7.0.0') >= 0) {
|
||||
$this->expectException(\TypeError::class);
|
||||
} else {
|
||||
@ -357,7 +356,7 @@ class WriterWithStyleTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$fileName = 'test_set_default_row_style.ods';
|
||||
$row = EntityFactory::createRow([
|
||||
new Cell('ods--11')
|
||||
new Cell('ods--11'),
|
||||
]);
|
||||
$dataRows = [$row];
|
||||
|
||||
@ -383,6 +382,7 @@ class WriterWithStyleTest extends \PHPUnit_Framework_TestCase
|
||||
$row = EntityFactory::createRow(array_map(function ($value) {
|
||||
return new Cell($value);
|
||||
}, $oneRow), $style);
|
||||
|
||||
return $row;
|
||||
}, $allRows);
|
||||
};
|
||||
|
@ -5,7 +5,6 @@ namespace Box\Spout\Writer\XLSX;
|
||||
use Box\Spout\Common\Type;
|
||||
use Box\Spout\TestUsingResource;
|
||||
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\Sheet;
|
||||
use Box\Spout\Writer\WriterFactory;
|
||||
|
@ -53,7 +53,7 @@ class WriterTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$row = $this->entityFactory->createRow([
|
||||
new Cell('xlsx--11'),
|
||||
new Cell('xlsx--12')
|
||||
new Cell('xlsx--12'),
|
||||
]);
|
||||
$writer->addRow($row);
|
||||
}
|
||||
@ -66,7 +66,7 @@ class WriterTest extends \PHPUnit_Framework_TestCase
|
||||
$writer = WriterFactory::create(Type::XLSX);
|
||||
$row = $this->entityFactory->createRow([
|
||||
new Cell('xlsx--11'),
|
||||
new Cell('xlsx--12')
|
||||
new Cell('xlsx--12'),
|
||||
]);
|
||||
$writer->addRows([$row]);
|
||||
}
|
||||
@ -386,12 +386,12 @@ class WriterTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testAddRowShouldWriteGivenDataToTheCorrectSheet()
|
||||
{
|
||||
|
||||
$arrayToRows = function(array $allRows) {
|
||||
$arrayToRows = function (array $allRows) {
|
||||
return array_map(function ($oneRow) {
|
||||
$row = $this->entityFactory->createRow(array_map(function ($value) {
|
||||
return new Cell($value);
|
||||
}, $oneRow));
|
||||
|
||||
return $row;
|
||||
}, $allRows);
|
||||
};
|
||||
@ -615,12 +615,13 @@ class WriterTest extends \PHPUnit_Framework_TestCase
|
||||
$writer->openToFile($resourcePath);
|
||||
$writer->addRows(array_map(function ($oneRow) {
|
||||
$row = $this->entityFactory->createRow(array_map(function ($value) {
|
||||
if(!$value instanceof Cell) {
|
||||
if (!$value instanceof Cell) {
|
||||
return new Cell($value);
|
||||
} else {
|
||||
return $value;
|
||||
}
|
||||
}, $oneRow));
|
||||
|
||||
return $row;
|
||||
}, $allRows));
|
||||
$writer->close();
|
||||
@ -651,6 +652,7 @@ class WriterTest extends \PHPUnit_Framework_TestCase
|
||||
$row = $this->entityFactory->createRow(array_map(function ($value) {
|
||||
return new Cell($value);
|
||||
}, $oneRow));
|
||||
|
||||
return $row;
|
||||
}, $allRows));
|
||||
|
||||
@ -660,6 +662,7 @@ class WriterTest extends \PHPUnit_Framework_TestCase
|
||||
$row = $this->entityFactory->createRow(array_map(function ($value) {
|
||||
return new Cell($value);
|
||||
}, $oneRow));
|
||||
|
||||
return $row;
|
||||
}, $allRows));
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ class WriterWithStyleTest extends \PHPUnit_Framework_TestCase
|
||||
$writer = WriterFactory::create(Type::XLSX);
|
||||
$row = EntityFactory::createRow([
|
||||
new Cell('xlsx--11'),
|
||||
new Cell('xlsx--12')
|
||||
new Cell('xlsx--12'),
|
||||
], $this->defaultStyle);
|
||||
$writer->addRow($row);
|
||||
}
|
||||
@ -55,7 +55,7 @@ class WriterWithStyleTest extends \PHPUnit_Framework_TestCase
|
||||
$writer = WriterFactory::create(Type::XLSX);
|
||||
$row = EntityFactory::createRow([
|
||||
new Cell('xlsx--11'),
|
||||
new Cell('xlsx--12')
|
||||
new Cell('xlsx--12'),
|
||||
], $this->defaultStyle);
|
||||
$writer->addRows([$row]);
|
||||
}
|
||||
@ -92,7 +92,7 @@ class WriterWithStyleTest extends \PHPUnit_Framework_TestCase
|
||||
$writer->openToFile($resourcePath);
|
||||
$row = EntityFactory::createRow([
|
||||
new Cell('xlsx--11'),
|
||||
new Cell('xlsx--12')
|
||||
new Cell('xlsx--12'),
|
||||
], $style);
|
||||
$writer->addRow($row);
|
||||
}
|
||||
@ -118,7 +118,7 @@ class WriterWithStyleTest extends \PHPUnit_Framework_TestCase
|
||||
$writer->openToFile($resourcePath);
|
||||
$row = EntityFactory::createRow([
|
||||
new Cell('xlsx--11'),
|
||||
new Cell('xlsx--12')
|
||||
new Cell('xlsx--12'),
|
||||
], $style);
|
||||
$writer->addRows([$row]);
|
||||
}
|
||||
@ -458,7 +458,7 @@ class WriterWithStyleTest extends \PHPUnit_Framework_TestCase
|
||||
$fileName = 'test_set_default_row_style.xlsx';
|
||||
|
||||
$row = EntityFactory::createRow([
|
||||
new Cell('xlsx--11')
|
||||
new Cell('xlsx--11'),
|
||||
]);
|
||||
$dataRows = [$row];
|
||||
|
||||
@ -552,17 +552,16 @@ class WriterWithStyleTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
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) {
|
||||
$row = EntityFactory::createRow(array_map(function ($value) {
|
||||
return new Cell($value);
|
||||
}, $oneRow), $style);
|
||||
|
||||
return $row;
|
||||
}, $allRows);
|
||||
};
|
||||
|
||||
|
||||
$this->createGeneratedFolderIfNeeded($fileName);
|
||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||
|
||||
@ -585,8 +584,6 @@ class WriterWithStyleTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
private function writeToXLSXFileWithDefaultStyle($allRows, $fileName, $defaultStyle)
|
||||
{
|
||||
|
||||
|
||||
$this->createGeneratedFolderIfNeeded($fileName);
|
||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user