Fix code style
This commit is contained in:
1 parent
740fcfb8c1
commit
b968513cb9
171 files changed
+517
-792
No files matched your search
@@ -11,8 +11,6 @@ use Box\Spout\Writer\Common\Manager\SheetManager;
|
||||
/**
|
||||
* Class EntityFactory
|
||||
* Factory to create entities
|
||||
*
|
||||
* @package Box\Spout\Writer\Common\Creator
|
||||
*/
|
||||
class EntityFactory
|
||||
{
|
||||
|
||||
@@ -8,8 +8,6 @@ use Box\Spout\Writer\Common\Manager\WorkbookManagerInterface;
|
||||
|
||||
/**
|
||||
* Interface ManagerFactoryInterface
|
||||
*
|
||||
* @package Box\Spout\Writer\Common\Creator
|
||||
*/
|
||||
interface ManagerFactoryInterface
|
||||
{
|
||||
|
||||
@@ -8,8 +8,6 @@ use Box\Spout\Writer\Common\Entity\Style\Color;
|
||||
|
||||
/**
|
||||
* Class BorderBuilder
|
||||
*
|
||||
* @package \Box\Spout\Writer\Common\Creator\Style
|
||||
*/
|
||||
class BorderBuilder
|
||||
{
|
||||
@@ -32,6 +30,7 @@ class BorderBuilder
|
||||
public function setBorderTop($color = Color::BLACK, $width = Border::WIDTH_MEDIUM, $style = Border::STYLE_SOLID)
|
||||
{
|
||||
$this->border->addPart(new BorderPart(Border::TOP, $color, $width, $style));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -44,6 +43,7 @@ class BorderBuilder
|
||||
public function setBorderRight($color = Color::BLACK, $width = Border::WIDTH_MEDIUM, $style = Border::STYLE_SOLID)
|
||||
{
|
||||
$this->border->addPart(new BorderPart(Border::RIGHT, $color, $width, $style));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -56,6 +56,7 @@ class BorderBuilder
|
||||
public function setBorderBottom($color = Color::BLACK, $width = Border::WIDTH_MEDIUM, $style = Border::STYLE_SOLID)
|
||||
{
|
||||
$this->border->addPart(new BorderPart(Border::BOTTOM, $color, $width, $style));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -68,6 +69,7 @@ class BorderBuilder
|
||||
public function setBorderLeft($color = Color::BLACK, $width = Border::WIDTH_MEDIUM, $style = Border::STYLE_SOLID)
|
||||
{
|
||||
$this->border->addPart(new BorderPart(Border::LEFT, $color, $width, $style));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,8 +8,6 @@ use Box\Spout\Writer\Common\Entity\Style\Style;
|
||||
/**
|
||||
* Class StyleBuilder
|
||||
* Builder to create new styles
|
||||
*
|
||||
* @package Box\Spout\Writer\Common\Creator\Style
|
||||
*/
|
||||
class StyleBuilder
|
||||
{
|
||||
@@ -33,6 +31,7 @@ class StyleBuilder
|
||||
public function setFontBold()
|
||||
{
|
||||
$this->style->setFontBold();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -45,6 +44,7 @@ class StyleBuilder
|
||||
public function setFontItalic()
|
||||
{
|
||||
$this->style->setFontItalic();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -57,6 +57,7 @@ class StyleBuilder
|
||||
public function setFontUnderline()
|
||||
{
|
||||
$this->style->setFontUnderline();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -69,6 +70,7 @@ class StyleBuilder
|
||||
public function setFontStrikethrough()
|
||||
{
|
||||
$this->style->setFontStrikethrough();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -82,6 +84,7 @@ class StyleBuilder
|
||||
public function setFontSize($fontSize)
|
||||
{
|
||||
$this->style->setFontSize($fontSize);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -95,6 +98,7 @@ class StyleBuilder
|
||||
public function setFontColor($fontColor)
|
||||
{
|
||||
$this->style->setFontColor($fontColor);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -108,6 +112,7 @@ class StyleBuilder
|
||||
public function setFontName($fontName)
|
||||
{
|
||||
$this->style->setFontName($fontName);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -121,6 +126,7 @@ class StyleBuilder
|
||||
public function setShouldWrapText($shouldWrap = true)
|
||||
{
|
||||
$this->style->setShouldWrapText($shouldWrap);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -133,6 +139,7 @@ class StyleBuilder
|
||||
public function setBorder(Border $border)
|
||||
{
|
||||
$this->style->setBorder($border);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -146,6 +153,7 @@ class StyleBuilder
|
||||
public function setBackgroundColor($color)
|
||||
{
|
||||
$this->style->setBackgroundColor($color);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,8 +6,6 @@ use Box\Spout\Writer\Common\Helper\CellHelper;
|
||||
|
||||
/**
|
||||
* Class Cell
|
||||
*
|
||||
* @package Box\Spout\Writer\Common\Entity
|
||||
*/
|
||||
class Cell
|
||||
{
|
||||
@@ -46,13 +44,13 @@ class Cell
|
||||
* The value of this cell
|
||||
* @var mixed|null
|
||||
*/
|
||||
protected $value = null;
|
||||
protected $value;
|
||||
|
||||
/**
|
||||
* The cell type
|
||||
* @var int|null
|
||||
*/
|
||||
protected $type = null;
|
||||
protected $type;
|
||||
|
||||
/**
|
||||
* Cell constructor.
|
||||
@@ -165,6 +163,6 @@ class Cell
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return (string)$this->value;
|
||||
return (string) $this->value;
|
||||
}
|
||||
}
|
||||
@@ -5,8 +5,6 @@ namespace Box\Spout\Writer\Common\Entity;
|
||||
/**
|
||||
* Class Options
|
||||
* Writers' options holder
|
||||
*
|
||||
* @package Box\Spout\Writer\Common\Entity
|
||||
*/
|
||||
abstract class Options
|
||||
{
|
||||
|
||||
@@ -7,8 +7,6 @@ use Box\Spout\Writer\Common\Manager\SheetManager;
|
||||
/**
|
||||
* Class Sheet
|
||||
* External representation of a worksheet
|
||||
*
|
||||
* @package Box\Spout\Writer\Common\Entity
|
||||
*/
|
||||
class Sheet
|
||||
{
|
||||
@@ -77,8 +75,8 @@ class Sheet
|
||||
*
|
||||
* @api
|
||||
* @param string $name Name of the sheet
|
||||
* @return Sheet
|
||||
* @throws \Box\Spout\Writer\Exception\InvalidSheetNameException If the sheet's name is invalid.
|
||||
* @return Sheet
|
||||
*/
|
||||
public function setName($name)
|
||||
{
|
||||
|
||||
@@ -4,8 +4,6 @@ namespace Box\Spout\Writer\Common\Entity\Style;
|
||||
|
||||
/**
|
||||
* Class Border
|
||||
*
|
||||
* @package \Box\Spout\Writer\Common\Entity\Style
|
||||
*/
|
||||
class Border
|
||||
{
|
||||
@@ -37,7 +35,7 @@ class Border
|
||||
|
||||
/**
|
||||
* @param string $name The name of the border part
|
||||
* @return null|BorderPart
|
||||
* @return BorderPart|null
|
||||
*/
|
||||
public function getPart($name)
|
||||
{
|
||||
@@ -81,6 +79,7 @@ class Border
|
||||
public function addPart(BorderPart $borderPart)
|
||||
{
|
||||
$this->parts[$borderPart->getName()] = $borderPart;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -8,8 +8,6 @@ use Box\Spout\Writer\Exception\Border\InvalidWidthException;
|
||||
|
||||
/**
|
||||
* Class BorderPart
|
||||
*
|
||||
* @package \Box\Spout\Writer\Common\Entity\Style
|
||||
*/
|
||||
class BorderPart
|
||||
{
|
||||
@@ -41,7 +39,7 @@ class BorderPart
|
||||
'solid',
|
||||
'dashed',
|
||||
'dotted',
|
||||
'double'
|
||||
'double',
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,8 +7,6 @@ use Box\Spout\Writer\Exception\InvalidColorException;
|
||||
/**
|
||||
* Class Color
|
||||
* This class provides constants and functions to work with colors
|
||||
*
|
||||
* @package Box\Spout\Writer\Common\Entity\Style
|
||||
*/
|
||||
class Color
|
||||
{
|
||||
@@ -52,8 +50,8 @@ class Color
|
||||
* Throws an exception is the color component value is outside of bounds (0 - 255)
|
||||
*
|
||||
* @param int $colorComponent
|
||||
* @return void
|
||||
* @throws \Box\Spout\Writer\Exception\InvalidColorException
|
||||
* @return void
|
||||
*/
|
||||
protected static function throwIfInvalidColorComponentValue($colorComponent)
|
||||
{
|
||||
|
||||
@@ -5,8 +5,6 @@ namespace Box\Spout\Writer\Common\Entity\Style;
|
||||
/**
|
||||
* Class Style
|
||||
* Represents a style to be applied to a cell
|
||||
*
|
||||
* @package Box\Spout\Writer\Common\Entity\Style
|
||||
*/
|
||||
class Style
|
||||
{
|
||||
@@ -16,7 +14,7 @@ class Style
|
||||
const DEFAULT_FONT_NAME = 'Arial';
|
||||
|
||||
/** @var int|null Style ID */
|
||||
private $id = null;
|
||||
private $id;
|
||||
|
||||
/** @var bool Whether the font should be bold */
|
||||
private $fontBold = false;
|
||||
@@ -62,18 +60,17 @@ class Style
|
||||
private $hasSetWrapText = false;
|
||||
|
||||
/** @var Border */
|
||||
private $border = null;
|
||||
private $border;
|
||||
|
||||
/** @var bool Whether border properties should be applied */
|
||||
private $shouldApplyBorder = false;
|
||||
|
||||
/** @var string Background color */
|
||||
private $backgroundColor = null;
|
||||
private $backgroundColor;
|
||||
|
||||
/** @var bool */
|
||||
private $hasSetBackgroundColor = false;
|
||||
|
||||
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
@@ -89,6 +86,7 @@ class Style
|
||||
public function setId($id)
|
||||
{
|
||||
$this->id = $id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -108,6 +106,7 @@ class Style
|
||||
{
|
||||
$this->shouldApplyBorder = true;
|
||||
$this->border = $border;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -135,6 +134,7 @@ class Style
|
||||
$this->fontBold = true;
|
||||
$this->hasSetFontBold = true;
|
||||
$this->shouldApplyFont = true;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -162,6 +162,7 @@ class Style
|
||||
$this->fontItalic = true;
|
||||
$this->hasSetFontItalic = true;
|
||||
$this->shouldApplyFont = true;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -189,6 +190,7 @@ class Style
|
||||
$this->fontUnderline = true;
|
||||
$this->hasSetFontUnderline = true;
|
||||
$this->shouldApplyFont = true;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -216,6 +218,7 @@ class Style
|
||||
$this->fontStrikethrough = true;
|
||||
$this->hasSetFontStrikethrough = true;
|
||||
$this->shouldApplyFont = true;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -244,6 +247,7 @@ class Style
|
||||
$this->fontSize = $fontSize;
|
||||
$this->hasSetFontSize = true;
|
||||
$this->shouldApplyFont = true;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -274,6 +278,7 @@ class Style
|
||||
$this->fontColor = $fontColor;
|
||||
$this->hasSetFontColor = true;
|
||||
$this->shouldApplyFont = true;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -302,6 +307,7 @@ class Style
|
||||
$this->fontName = $fontName;
|
||||
$this->hasSetFontName = true;
|
||||
$this->shouldApplyFont = true;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -329,6 +335,7 @@ class Style
|
||||
{
|
||||
$this->shouldWrapText = $shouldWrap;
|
||||
$this->hasSetWrapText = true;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -357,6 +364,7 @@ class Style
|
||||
{
|
||||
$this->hasSetBackgroundColor = true;
|
||||
$this->backgroundColor = $color;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -369,7 +377,6 @@ class Style
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return bool Whether the background color should be applied
|
||||
*/
|
||||
public function shouldApplyBackgroundColor()
|
||||
|
||||
@@ -5,8 +5,6 @@ namespace Box\Spout\Writer\Common\Entity;
|
||||
/**
|
||||
* Class Workbook
|
||||
* Entity describing a workbook
|
||||
*
|
||||
* @package Box\Spout\Writer\Common\Entity
|
||||
*/
|
||||
class Workbook
|
||||
{
|
||||
@@ -47,4 +45,4 @@ class Workbook
|
||||
{
|
||||
return $this->internalId;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,15 +5,13 @@ namespace Box\Spout\Writer\Common\Entity;
|
||||
/**
|
||||
* Class Worksheet
|
||||
* Entity describing a Worksheet
|
||||
*
|
||||
* @package Box\Spout\Writer\Common\Entity
|
||||
*/
|
||||
class Worksheet
|
||||
{
|
||||
/** @var string Path to the XML file that will contain the sheet data */
|
||||
private $filePath;
|
||||
|
||||
/** @var Resource Pointer to the sheet data file (e.g. xl/worksheets/sheet1.xml) */
|
||||
/** @var resource Pointer to the sheet data file (e.g. xl/worksheets/sheet1.xml) */
|
||||
private $filePointer;
|
||||
|
||||
/** @var Sheet The "external" sheet */
|
||||
@@ -49,7 +47,7 @@ class Worksheet
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Resource
|
||||
* @return resource
|
||||
*/
|
||||
public function getFilePointer()
|
||||
{
|
||||
@@ -57,7 +55,7 @@ class Worksheet
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Resource $filePointer
|
||||
* @param resource $filePointer
|
||||
*/
|
||||
public function setFilePointer($filePointer)
|
||||
{
|
||||
@@ -112,4 +110,4 @@ class Worksheet
|
||||
// sheet index is zero-based, while ID is 1-based
|
||||
return $this->externalSheet->getIndex() + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,8 +5,6 @@ namespace Box\Spout\Writer\Common\Helper;
|
||||
/**
|
||||
* Class CellHelper
|
||||
* This class provides helper functions when working with cells
|
||||
*
|
||||
* @package Box\Spout\Writer\Common\Helper
|
||||
*/
|
||||
class CellHelper
|
||||
{
|
||||
@@ -36,8 +34,7 @@ class CellHelper
|
||||
$cellIndex = chr($capitalAAsciiValue + $modulus) . $cellIndex;
|
||||
|
||||
// substracting 1 because it's zero-based
|
||||
$columnIndex = intval($columnIndex / 26) - 1;
|
||||
|
||||
$columnIndex = (int) ($columnIndex / 26) - 1;
|
||||
} while ($columnIndex >= 0);
|
||||
|
||||
self::$columnIndexToCellIndexCache[$originalColumnIndex] = $cellIndex;
|
||||
@@ -74,6 +71,7 @@ class CellHelper
|
||||
public static function isNumeric($value)
|
||||
{
|
||||
$valueType = gettype($value);
|
||||
|
||||
return ($valueType === 'integer' || $valueType === 'double');
|
||||
}
|
||||
|
||||
|
||||
@@ -2,22 +2,20 @@
|
||||
|
||||
namespace Box\Spout\Writer\Common\Helper;
|
||||
|
||||
use \Box\Spout\Common\Helper\FileSystemHelperInterface;
|
||||
use Box\Spout\Common\Helper\FileSystemHelperInterface;
|
||||
|
||||
/**
|
||||
* Class FileSystemHelperInterface
|
||||
* This interface describes helper functions to help with the file system operations
|
||||
* like files/folders creation & deletion
|
||||
*
|
||||
* @package Box\Spout\Writer\Common\Helper
|
||||
*/
|
||||
interface FileSystemWithRootFolderHelperInterface extends FileSystemHelperInterface
|
||||
{
|
||||
/**
|
||||
* Creates all the folders needed to create a spreadsheet, as well as the files that won't change.
|
||||
*
|
||||
* @return void
|
||||
* @throws \Box\Spout\Common\Exception\IOException If unable to create at least one of the base folders
|
||||
* @return void
|
||||
*/
|
||||
public function createBaseFilesAndFolders();
|
||||
|
||||
|
||||
@@ -7,8 +7,6 @@ use Box\Spout\Writer\Common\Creator\EntityFactory;
|
||||
/**
|
||||
* Class ZipHelper
|
||||
* This class provides helper functions to create zip files
|
||||
*
|
||||
* @package Box\Spout\Writer\Common\Helper
|
||||
*/
|
||||
class ZipHelper
|
||||
{
|
||||
@@ -40,7 +38,7 @@ class ZipHelper
|
||||
$zip = $this->entityFactory->createZipArchive();
|
||||
$zipFilePath = $tmpFolderPath . self::ZIP_EXTENSION;
|
||||
|
||||
$zip->open($zipFilePath, \ZipArchive::CREATE|\ZipArchive::OVERWRITE);
|
||||
$zip->open($zipFilePath, \ZipArchive::CREATE | \ZipArchive::OVERWRITE);
|
||||
|
||||
return $zip;
|
||||
}
|
||||
@@ -184,6 +182,7 @@ class ZipHelper
|
||||
protected function getNormalizedRealPath($path)
|
||||
{
|
||||
$realPath = realpath($path);
|
||||
|
||||
return str_replace(DIRECTORY_SEPARATOR, '/', $realPath);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,8 +9,6 @@ use Box\Spout\Writer\Exception\InvalidSheetNameException;
|
||||
/**
|
||||
* Class SheetManager
|
||||
* Sheet manager
|
||||
*
|
||||
* @package Box\Spout\Writer\Common\Manager
|
||||
*/
|
||||
class SheetManager
|
||||
{
|
||||
@@ -42,8 +40,8 @@ class SheetManager
|
||||
*
|
||||
* @param string $name
|
||||
* @param Sheet $sheet The sheet whose future name is checked
|
||||
* @return void
|
||||
* @throws \Box\Spout\Writer\Exception\InvalidSheetNameException If the sheet's name is invalid.
|
||||
* @return void
|
||||
*/
|
||||
public function throwIfNameIsInvalid($name, Sheet $sheet)
|
||||
{
|
||||
|
||||
@@ -7,8 +7,6 @@ use Box\Spout\Writer\Common\Entity\Style\Style;
|
||||
/**
|
||||
* Class StyleManager
|
||||
* Manages styles to be applied to a cell
|
||||
*
|
||||
* @package Box\Spout\Writer\Common\Manager\Style
|
||||
*/
|
||||
class StyleManager implements StyleManagerInterface
|
||||
{
|
||||
@@ -57,6 +55,7 @@ class StyleManager implements StyleManagerInterface
|
||||
public function applyExtraStylesIfNeeded($style, $dataRow)
|
||||
{
|
||||
$updatedStyle = $this->applyWrapTextIfCellContainsNewLine($style, $dataRow);
|
||||
|
||||
return $updatedStyle;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,8 +6,6 @@ use Box\Spout\Writer\Common\Entity\Style\Style;
|
||||
|
||||
/**
|
||||
* Interface StyleHManagernterface
|
||||
*
|
||||
* @package Box\Spout\Writer\Common\Manager\Style
|
||||
*/
|
||||
interface StyleManagerInterface
|
||||
{
|
||||
|
||||
@@ -2,15 +2,11 @@
|
||||
|
||||
namespace Box\Spout\Writer\Common\Manager\Style;
|
||||
|
||||
use Box\Spout\Writer\Common\Entity\Style\Color;
|
||||
use Box\Spout\Writer\Common\Entity\Style\Style;
|
||||
use Box\Spout\Writer\XLSX\Helper\BorderHelper;
|
||||
|
||||
/**
|
||||
* Class StyleMerger
|
||||
* Takes care of merging styles together
|
||||
*
|
||||
* @package Box\Spout\Writer\Common\Manager\Style
|
||||
*/
|
||||
class StyleMerger
|
||||
{
|
||||
|
||||
@@ -7,8 +7,6 @@ use Box\Spout\Writer\Common\Entity\Style\Style;
|
||||
/**
|
||||
* Class StyleRegistry
|
||||
* Registry for all used styles
|
||||
*
|
||||
* @package Box\Spout\Writer\Common\Manager\Style
|
||||
*/
|
||||
class StyleRegistry
|
||||
{
|
||||
@@ -72,6 +70,7 @@ class StyleRegistry
|
||||
protected function getStyleFromSerializedStyle($serializedStyle)
|
||||
{
|
||||
$styleId = $this->serializedStyleToStyleIdMappingTable[$serializedStyle];
|
||||
|
||||
return $this->styleIdToStyleMappingTable[$styleId];
|
||||
}
|
||||
|
||||
|
||||
@@ -4,23 +4,21 @@ namespace Box\Spout\Writer\Common\Manager;
|
||||
|
||||
use Box\Spout\Common\Exception\IOException;
|
||||
use Box\Spout\Common\Manager\OptionsManagerInterface;
|
||||
use Box\Spout\Writer\Common\Creator\EntityFactory;
|
||||
use Box\Spout\Writer\Common\Creator\ManagerFactoryInterface;
|
||||
use Box\Spout\Writer\Common\Helper\FileSystemWithRootFolderHelperInterface;
|
||||
use Box\Spout\Writer\Common\Entity\Options;
|
||||
use Box\Spout\Writer\Common\Manager\Style\StyleManagerInterface;
|
||||
use Box\Spout\Writer\Common\Entity\Sheet;
|
||||
use Box\Spout\Writer\Common\Entity\Style\Style;
|
||||
use Box\Spout\Writer\Common\Entity\Workbook;
|
||||
use Box\Spout\Writer\Common\Entity\Worksheet;
|
||||
use Box\Spout\Writer\Common\Helper\FileSystemWithRootFolderHelperInterface;
|
||||
use Box\Spout\Writer\Common\Manager\Style\StyleManagerInterface;
|
||||
use Box\Spout\Writer\Exception\SheetNotFoundException;
|
||||
use Box\Spout\Writer\Exception\WriterException;
|
||||
use Box\Spout\Writer\Common\Creator\EntityFactory;
|
||||
use Box\Spout\Writer\Common\Entity\Style\Style;
|
||||
|
||||
/**
|
||||
* Class WorkbookManagerAbstract
|
||||
* Abstract workbook manager, providing the generic interfaces to work with workbook.
|
||||
*
|
||||
* @package Box\Spout\Writer\Common\Manager
|
||||
*/
|
||||
abstract class WorkbookManagerAbstract implements WorkbookManagerInterface
|
||||
{
|
||||
@@ -48,7 +46,6 @@ abstract class WorkbookManagerAbstract implements WorkbookManagerInterface
|
||||
/** @var Worksheet The worksheet where data will be written to */
|
||||
protected $currentWorksheet;
|
||||
|
||||
|
||||
/**
|
||||
* @param Workbook $workbook
|
||||
* @param OptionsManagerInterface $optionsManager
|
||||
@@ -65,8 +62,8 @@ abstract class WorkbookManagerAbstract implements WorkbookManagerInterface
|
||||
StyleManagerInterface $styleManager,
|
||||
FileSystemWithRootFolderHelperInterface $fileSystemHelper,
|
||||
EntityFactory $entityFactory,
|
||||
ManagerFactoryInterface $managerFactory)
|
||||
{
|
||||
ManagerFactoryInterface $managerFactory
|
||||
) {
|
||||
$this->workbook = $workbook;
|
||||
$this->optionManager = $optionsManager;
|
||||
$this->worksheetManager = $worksheetManager;
|
||||
@@ -99,8 +96,8 @@ abstract class WorkbookManagerAbstract implements WorkbookManagerInterface
|
||||
* Creates a new sheet in the workbook and make it the current sheet.
|
||||
* The writing will resume where it stopped (i.e. data won't be truncated).
|
||||
*
|
||||
* @return Worksheet The created sheet
|
||||
* @throws IOException If unable to open the sheet for writing
|
||||
* @return Worksheet The created sheet
|
||||
*/
|
||||
public function addNewSheetAndMakeItCurrent()
|
||||
{
|
||||
@@ -113,8 +110,8 @@ abstract class WorkbookManagerAbstract implements WorkbookManagerInterface
|
||||
/**
|
||||
* Creates a new sheet in the workbook. The current sheet remains unchanged.
|
||||
*
|
||||
* @return Worksheet The created sheet
|
||||
* @throws \Box\Spout\Common\Exception\IOException If unable to open the sheet for writing
|
||||
* @return Worksheet The created sheet
|
||||
*/
|
||||
private function addNewSheet()
|
||||
{
|
||||
@@ -158,8 +155,8 @@ abstract class WorkbookManagerAbstract implements WorkbookManagerInterface
|
||||
* The writing will resume where it stopped (i.e. data won't be truncated).
|
||||
*
|
||||
* @param Sheet $sheet The "external" sheet to set as current
|
||||
* @return void
|
||||
* @throws SheetNotFoundException If the given sheet does not exist in the workbook
|
||||
* @return void
|
||||
*/
|
||||
public function setCurrentSheet(Sheet $sheet)
|
||||
{
|
||||
@@ -208,9 +205,9 @@ abstract class WorkbookManagerAbstract implements WorkbookManagerInterface
|
||||
* @param array $dataRow Array containing data to be written. Cannot be empty.
|
||||
* Example $dataRow = ['data1', 1234, null, '', 'data5'];
|
||||
* @param Style $style Style to be applied to the row.
|
||||
* @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
|
||||
*/
|
||||
public function addRowToCurrentWorksheet($dataRow, Style $style)
|
||||
{
|
||||
@@ -238,6 +235,7 @@ abstract class WorkbookManagerAbstract implements WorkbookManagerInterface
|
||||
private function hasCurrentWorkseetReachedMaxRows()
|
||||
{
|
||||
$currentWorksheet = $this->getCurrentWorksheet();
|
||||
|
||||
return ($currentWorksheet->getLastWrittenRowIndex() >= $this->getMaxRowsPerWorksheet());
|
||||
}
|
||||
|
||||
@@ -248,8 +246,8 @@ abstract class WorkbookManagerAbstract implements WorkbookManagerInterface
|
||||
* @param array $dataRow Array containing data to be written. Cannot be empty.
|
||||
* Example $dataRow = ['data1', 1234, null, '', 'data5'];
|
||||
* @param Style $style Style to be applied to the row.
|
||||
* @return void
|
||||
* @throws WriterException If unable to write data
|
||||
* @return void
|
||||
*/
|
||||
private function addRowWithStyleToWorksheet(Worksheet $worksheet, $dataRow, Style $style)
|
||||
{
|
||||
|
||||
@@ -4,17 +4,15 @@ 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\Workbook;
|
||||
use Box\Spout\Writer\Common\Entity\Worksheet;
|
||||
use Box\Spout\Writer\Exception\SheetNotFoundException;
|
||||
use Box\Spout\Writer\Exception\WriterException;
|
||||
use Box\Spout\Writer\Common\Entity\Style\Style;
|
||||
|
||||
/**
|
||||
* Interface WorkbookManagerInterface
|
||||
* workbook manager interface, providing the generic interfaces to work with workbook.
|
||||
*
|
||||
* @package Box\Spout\Writer\Common\Manager
|
||||
*/
|
||||
interface WorkbookManagerInterface
|
||||
{
|
||||
@@ -27,8 +25,8 @@ interface WorkbookManagerInterface
|
||||
* Creates a new sheet in the workbook and make it the current sheet.
|
||||
* The writing will resume where it stopped (i.e. data won't be truncated).
|
||||
*
|
||||
* @return Worksheet The created sheet
|
||||
* @throws IOException If unable to open the sheet for writing
|
||||
* @return Worksheet The created sheet
|
||||
*/
|
||||
public function addNewSheetAndMakeItCurrent();
|
||||
|
||||
@@ -49,8 +47,8 @@ interface WorkbookManagerInterface
|
||||
* The writing will resume where it stopped (i.e. data won't be truncated).
|
||||
*
|
||||
* @param Sheet $sheet The "external" sheet to set as current
|
||||
* @return void
|
||||
* @throws SheetNotFoundException If the given sheet does not exist in the workbook
|
||||
* @return void
|
||||
*/
|
||||
public function setCurrentSheet(Sheet $sheet);
|
||||
|
||||
@@ -62,9 +60,9 @@ interface WorkbookManagerInterface
|
||||
* @param array $dataRow Array containing data to be written. Cannot be empty.
|
||||
* Example $dataRow = ['data1', 1234, null, '', 'data5'];
|
||||
* @param Style $style Style to be applied to the row.
|
||||
* @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
|
||||
*/
|
||||
public function addRowToCurrentWorksheet($dataRow, Style $style);
|
||||
|
||||
@@ -77,4 +75,4 @@ interface WorkbookManagerInterface
|
||||
* @return void
|
||||
*/
|
||||
public function close($finalFilePointer);
|
||||
}
|
||||
}
|
||||
@@ -2,14 +2,12 @@
|
||||
|
||||
namespace Box\Spout\Writer\Common\Manager;
|
||||
|
||||
use Box\Spout\Writer\Common\Entity\Worksheet;
|
||||
use Box\Spout\Writer\Common\Entity\Style\Style;
|
||||
use Box\Spout\Writer\Common\Entity\Worksheet;
|
||||
|
||||
/**
|
||||
* Interface WorksheetManagerInterface
|
||||
* Inteface for worksheet managers, providing the generic interfaces to work with worksheets.
|
||||
*
|
||||
* @package Box\Spout\Writer\Common\Manager
|
||||
*/
|
||||
interface WorksheetManagerInterface
|
||||
{
|
||||
@@ -20,9 +18,9 @@ interface WorksheetManagerInterface
|
||||
* @param array $dataRow Array containing data to be written. Cannot be empty.
|
||||
* Example $dataRow = ['data1', 1234, null, '', 'data5'];
|
||||
* @param Style $rowStyle Style to be applied to the row. NULL means use default style.
|
||||
* @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
|
||||
*/
|
||||
public function addRow(Worksheet $worksheet, $dataRow, $rowStyle);
|
||||
|
||||
@@ -30,8 +28,8 @@ interface WorksheetManagerInterface
|
||||
* Prepares the worksheet to accept data
|
||||
*
|
||||
* @param Worksheet $worksheet The worksheet to start
|
||||
* @return void
|
||||
* @throws \Box\Spout\Common\Exception\IOException If the sheet data file cannot be opened for writing
|
||||
* @return void
|
||||
*/
|
||||
public function startSheet(Worksheet $worksheet);
|
||||
|
||||
@@ -42,4 +40,4 @@ interface WorksheetManagerInterface
|
||||
* @return void
|
||||
*/
|
||||
public function close(Worksheet $worksheet);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user