Fix code style

This commit is contained in:
Adrien Loison committed 2017-09-06 00:33:43 +02:00
1 parent 740fcfb8c1
commit b968513cb9
171 files changed
+517 -792

No files matched your search

@@ -2,15 +2,13 @@
namespace Box\Spout\Writer\XLSX\Manager;
use Box\Spout\Writer\Common\Entity\Options;
use Box\Spout\Common\Manager\OptionsManagerAbstract;
use Box\Spout\Writer\Common\Creator\Style\StyleBuilder;
use Box\Spout\Writer\Common\Entity\Options;
/**
* Class OptionsManager
* XLSX Writer options manager
*
* @package Box\Spout\Writer\XLSX\Manager
*/
class OptionsManager extends OptionsManagerAbstract
{
@@ -32,7 +30,7 @@ class OptionsManager extends OptionsManagerAbstract
}
/**
* @inheritdoc
* {@inheritdoc}
*/
protected function getSupportedOptions()
{
@@ -45,7 +43,7 @@ class OptionsManager extends OptionsManagerAbstract
}
/**
* @inheritdoc
* {@inheritdoc}
*/
protected function setDefaultOptions()
{
@@ -8,14 +8,12 @@ use Box\Spout\Common\Helper\Escaper;
/**
* Class SharedStringsManager
* This class provides functions to write shared strings
*
* @package Box\Spout\Writer\XLSX\Manager
*/
class SharedStringsManager
{
const SHARED_STRINGS_FILE_NAME = 'sharedStrings.xml';
const SHARED_STRINGS_XML_FILE_FIRST_PART_HEADER = <<<EOD
const SHARED_STRINGS_XML_FILE_FIRST_PART_HEADER = <<<'EOD'
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<sst xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"
EOD;
@@ -56,8 +54,8 @@ EOD;
/**
* Checks if the book has been created. Throws an exception if not created yet.
*
* @return void
* @throws \Box\Spout\Common\Exception\IOException If the sheet data file cannot be opened for writing
* @return void
*/
protected function throwIfSharedStringsFilePointerIsNotAvailable()
{
@@ -9,8 +9,6 @@ use Box\Spout\Writer\XLSX\Helper\BorderHelper;
/**
* Class StyleManager
* Manages styles to be applied to a cell
*
* @package Box\Spout\Writer\XLSX\Manager\Style
*/
class StyleManager extends \Box\Spout\Writer\Common\Manager\Style\StyleManager
{
@@ -38,7 +36,6 @@ class StyleManager extends \Box\Spout\Writer\Common\Manager\Style\StyleManager
return ($hasStyleCustomFill || $hasStyleCustomBorders);
}
/**
* Returns the content of the "styles.xml" file, given a list of styles.
*
@@ -46,7 +43,7 @@ class StyleManager extends \Box\Spout\Writer\Common\Manager\Style\StyleManager
*/
public function getStylesXMLFileContent()
{
$content = <<<EOD
$content = <<<'EOD'
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
EOD;
@@ -58,7 +55,7 @@ EOD;
$content .= $this->getCellXfsSectionContent();
$content .= $this->getCellStylesSectionContent();
$content .= <<<EOD
$content .= <<<'EOD'
</styleSheet>
EOD;
@@ -187,7 +184,7 @@ EOD;
*/
protected function getCellStyleXfsSectionContent()
{
return <<<EOD
return <<<'EOD'
<cellStyleXfs count="1">
<xf borderId="0" fillId="0" fontId="0" numFmtId="0"/>
</cellStyleXfs>
@@ -239,7 +236,7 @@ EOD;
*/
protected function getCellStylesSectionContent()
{
return <<<EOD
return <<<'EOD'
<cellStyles count="1">
<cellStyle builtinId="0" name="Normal" xfId="0"/>
</cellStyles>
@@ -7,8 +7,6 @@ use Box\Spout\Writer\Common\Entity\Style\Style;
/**
* Class StyleRegistry
* Registry for all used styles
*
* @package Box\Spout\Writer\XLSX\Manager\Style
*/
class StyleRegistry extends \Box\Spout\Writer\Common\Manager\Style\StyleRegistry
{
@@ -80,7 +78,6 @@ class StyleRegistry extends \Box\Spout\Writer\Common\Manager\Style\StyleRegistry
$this->registeredFills[$backgroundColor] = $styleId;
$this->styleIdToFillMappingTable[$styleId] = $this->fillIndex++;
}
} else {
// The fillId maps a style to a fill declaration
// When there is no background color definition - we default to 0
@@ -122,7 +119,6 @@ class StyleRegistry extends \Box\Spout\Writer\Common\Manager\Style\StyleRegistry
$this->registeredBorders[$serializedBorder] = $styleId;
$this->styleIdToBorderMappingTable[$styleId] = count($this->registeredBorders);
}
} else {
// If no border should be applied - the mapping is the default border: 0
$this->styleIdToBorderMappingTable[$styleId] = 0;
@@ -10,8 +10,6 @@ use Box\Spout\Writer\XLSX\Manager\Style\StyleManager;
/**
* Class WorkbookManager
* XLSX workbook manager, providing the interfaces to work with workbook.
*
* @package Box\Spout\Writer\XLSX\Manager
*/
class WorkbookManager extends WorkbookManagerAbstract
{
@@ -45,6 +43,7 @@ class WorkbookManager extends WorkbookManagerAbstract
public function getWorksheetFilePath(Sheet $sheet)
{
$worksheetFilesFolder = $this->fileSystemHelper->getXlWorksheetsFolder();
return $worksheetFilesFolder . '/' . strtolower($sheet->getName()) . '.xml';
}
@@ -75,4 +74,4 @@ class WorkbookManager extends WorkbookManagerAbstract
->createStylesFile($this->styleManager)
->zipRootFolderAndCopyToStream($finalFilePointer);
}
}
}
@@ -5,21 +5,19 @@ namespace Box\Spout\Writer\XLSX\Manager;
use Box\Spout\Common\Exception\InvalidArgumentException;
use Box\Spout\Common\Exception\IOException;
use Box\Spout\Common\Helper\StringHelper;
use Box\Spout\Writer\Common\Creator\EntityFactory;
use Box\Spout\Writer\Common\Helper\CellHelper;
use Box\Spout\Common\Manager\OptionsManagerInterface;
use Box\Spout\Writer\Common\Entity\Options;
use Box\Spout\Writer\Common\Creator\EntityFactory;
use Box\Spout\Writer\Common\Entity\Cell;
use Box\Spout\Writer\Common\Entity\Worksheet;
use Box\Spout\Writer\Common\Manager\WorksheetManagerInterface;
use Box\Spout\Writer\Common\Entity\Options;
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;
use Box\Spout\Writer\XLSX\Manager\Style\StyleManager;
/**
* Class WorksheetManager
* XLSX worksheet manager, providing the interfaces to work with XLSX worksheets.
*
* @package Box\Spout\Writer\XLSX\Manager
*/
class WorksheetManager implements WorksheetManagerInterface
{
@@ -31,7 +29,7 @@ class WorksheetManager implements WorksheetManagerInterface
*/
const MAX_CHARACTERS_PER_CELL = 32767;
const SHEET_XML_FILE_HEADER = <<<EOD
const SHEET_XML_FILE_HEADER = <<<'EOD'
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
EOD;
@@ -70,8 +68,8 @@ EOD;
SharedStringsManager $sharedStringsManager,
\Box\Spout\Common\Helper\Escaper\XLSX $stringsEscaper,
StringHelper $stringHelper,
EntityFactory $entityFactory)
{
EntityFactory $entityFactory
) {
$this->shouldUseInlineStrings = $optionsManager->getOption(Options::SHOULD_USE_INLINE_STRINGS);
$this->styleManager = $styleManager;
$this->sharedStringsManager = $sharedStringsManager;
@@ -88,13 +86,12 @@ EOD;
return $this->sharedStringsManager;
}
/**
* 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)
{
@@ -111,8 +108,8 @@ EOD;
* Checks if the sheet has been sucessfully created. Throws an exception if not.
*
* @param bool|resource $sheetFilePointer Pointer to the sheet data file or FALSE if unable to open the file
* @return void
* @throws IOException If the sheet data file cannot be opened for writing
* @return void
*/
private function throwIfSheetFilePointerIsNotAvailable($sheetFilePointer)
{
@@ -128,9 +125,9 @@ EOD;
* @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 IOException If the data cannot be written
* @throws InvalidArgumentException If a cell value's type is not supported
* @return void
*/
public function addRow(Worksheet $worksheet, $dataRow, $rowStyle)
{
@@ -162,9 +159,9 @@ EOD;
* @param array $dataRow Array containing data to be written. Cannot be empty.
* Example $dataRow = ['data1', 1234, null, '', 'data5'];
* @param \Box\Spout\Writer\Common\Entity\Style\Style $style 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
*/
private function addNonEmptyRow(Worksheet $worksheet, $dataRow, $style)
{
@@ -174,7 +171,7 @@ EOD;
$rowXML = '<row r="' . $rowIndex . '" spans="1:' . $numCells . '">';
foreach($dataRow as $cellValue) {
foreach ($dataRow as $cellValue) {
$rowXML .= $this->getCellXML($rowIndex, $cellNumber, $cellValue, $style->getId());
$cellNumber++;
}
@@ -194,8 +191,8 @@ EOD;
* @param int $cellNumber
* @param mixed $cellValue
* @param int $styleId
* @return string
* @throws InvalidArgumentException If the given value cannot be processed
* @return string
*/
private function getCellXML($rowIndex, $cellNumber, $cellValue, $styleId)
{
@@ -203,7 +200,7 @@ EOD;
$cellXML = '<c r="' . $columnIndex . $rowIndex . '"';
$cellXML .= ' s="' . $styleId . '"';
/** @TODO Remove code duplication with ODS writer: https://github.com/box/spout/pull/383#discussion_r113292746 */
/* @TODO Remove code duplication with ODS writer: https://github.com/box/spout/pull/383#discussion_r113292746 */
if ($cellValue instanceof Cell) {
$cell = $cellValue;
} else {
@@ -212,11 +209,11 @@ EOD;
if ($cell->isString()) {
$cellXML .= $this->getCellXMLFragmentForNonEmptyString($cell->getValue());
} else if ($cell->isBoolean()) {
$cellXML .= ' t="b"><v>' . intval($cell->getValue()) . '</v></c>';
} else if ($cell->isNumeric()) {
} elseif ($cell->isBoolean()) {
$cellXML .= ' t="b"><v>' . (int) ($cell->getValue()) . '</v></c>';
} elseif ($cell->isNumeric()) {
$cellXML .= '><v>' . $cell->getValue() . '</v></c>';
} else if ($cell->isEmpty()) {
} elseif ($cell->isEmpty()) {
if ($this->styleManager->shouldApplyStyleOnEmptyCell($styleId)) {
$cellXML .= '/>';
} else {
@@ -235,8 +232,8 @@ EOD;
* Returns the XML fragment for a cell containing a non empty string
*
* @param string $cellValue The cell value
* @return string The XML fragment representing the cell
* @throws InvalidArgumentException If the string exceeds the maximum number of characters allowed per cell
* @return string The XML fragment representing the cell
*/
private function getCellXMLFragmentForNonEmptyString($cellValue)
{