PSR-2 code style

This commit is contained in:
Alexander Hofstede 2019-12-13 12:43:36 +01:00
parent 80487f1ac1
commit 4b9eb5b031
3 changed files with 35 additions and 25 deletions

View File

@ -171,8 +171,8 @@ abstract class WorkbookManagerAbstract implements WorkbookManagerInterface
* The writing will resume where it stopped (i.e. data won't be truncated). * The writing will resume where it stopped (i.e. data won't be truncated).
* *
* @param Sheet $sheet The "external" sheet to set as current * @param Sheet $sheet The "external" sheet to set as current
* @throws SheetNotFoundException If the given sheet does not exist in the workbook
* @return void * @return void
* @throws SheetNotFoundException If the given sheet does not exist in the workbook
*/ */
public function setCurrentSheet(Sheet $sheet) public function setCurrentSheet(Sheet $sheet)
{ {
@ -291,14 +291,16 @@ abstract class WorkbookManagerAbstract implements WorkbookManagerInterface
/** /**
* @param float|null $width * @param float|null $width
*/ */
public function setDefaultColumnWidth(float $width) { public function setDefaultColumnWidth(float $width)
{
$this->worksheetManager->setDefaultColumnWidth($width); $this->worksheetManager->setDefaultColumnWidth($width);
} }
/** /**
* @param float|null $height * @param float|null $height
*/ */
public function setDefaultRowHeight(float $height) { public function setDefaultRowHeight(float $height)
{
$this->worksheetManager->setDefaultRowHeight($height); $this->worksheetManager->setDefaultRowHeight($height);
} }
@ -306,7 +308,8 @@ abstract class WorkbookManagerAbstract implements WorkbookManagerInterface
* @param float $width * @param float $width
* @param array $columns One or more columns with this width * @param array $columns One or more columns with this width
*/ */
public function setColumnWidth(float $width, ...$columns) { public function setColumnWidth(float $width, ...$columns)
{
$this->worksheetManager->setColumnWidth($width, ...$columns); $this->worksheetManager->setColumnWidth($width, ...$columns);
} }
@ -315,7 +318,8 @@ abstract class WorkbookManagerAbstract implements WorkbookManagerInterface
* @param int $start First column index of the range * @param int $start First column index of the range
* @param int $end Last column index of the range * @param int $end Last column index of the range
*/ */
public function setColumnWidthForRange(float $width, int $start, int $end) { public function setColumnWidthForRange(float $width, int $start, int $end)
{
$this->worksheetManager->setColumnWidthForRange($width, $start, $end); $this->worksheetManager->setColumnWidthForRange($width, $start, $end);
} }

View File

@ -50,8 +50,8 @@ abstract class WriterMultiSheetsAbstract extends WriterAbstract
* This must be set before opening the writer. * This must be set before opening the writer.
* *
* @param bool $shouldCreateNewSheetsAutomatically Whether new sheets should be automatically created when the max rows limit per sheet is reached * @param bool $shouldCreateNewSheetsAutomatically Whether new sheets should be automatically created when the max rows limit per sheet is reached
* @throws WriterAlreadyOpenedException If the writer was already opened
* @return WriterMultiSheetsAbstract * @return WriterMultiSheetsAbstract
* @throws WriterAlreadyOpenedException If the writer was already opened
*/ */
public function setShouldCreateNewSheetsAutomatically($shouldCreateNewSheetsAutomatically) public function setShouldCreateNewSheetsAutomatically($shouldCreateNewSheetsAutomatically)
{ {
@ -76,8 +76,8 @@ abstract class WriterMultiSheetsAbstract extends WriterAbstract
/** /**
* Returns all the workbook's sheets * Returns all the workbook's sheets
* *
* @throws WriterNotOpenedException If the writer has not been opened yet
* @return Sheet[] All the workbook's sheets * @return Sheet[] All the workbook's sheets
* @throws WriterNotOpenedException If the writer has not been opened yet
*/ */
public function getSheets() public function getSheets()
{ {
@ -112,8 +112,8 @@ abstract class WriterMultiSheetsAbstract extends WriterAbstract
/** /**
* Returns the current sheet * Returns the current sheet
* *
* @throws WriterNotOpenedException If the writer has not been opened yet
* @return Sheet The current sheet * @return Sheet The current sheet
* @throws WriterNotOpenedException If the writer has not been opened yet
*/ */
public function getCurrentSheet() public function getCurrentSheet()
{ {
@ -127,9 +127,9 @@ abstract class WriterMultiSheetsAbstract extends WriterAbstract
* The writing will resume where it stopped (i.e. data won't be truncated). * The writing will resume where it stopped (i.e. data won't be truncated).
* *
* @param Sheet $sheet The sheet to set as current * @param Sheet $sheet The sheet to set as current
* @throws WriterNotOpenedException If the writer has not been opened yet
* @throws SheetNotFoundException If the given sheet does not exist in the workbook
* @return void * @return void
* @throws SheetNotFoundException If the given sheet does not exist in the workbook
* @throws WriterNotOpenedException If the writer has not been opened yet
*/ */
public function setCurrentSheet($sheet) public function setCurrentSheet($sheet)
{ {
@ -162,7 +162,8 @@ abstract class WriterMultiSheetsAbstract extends WriterAbstract
* @param array $columns One or more columns with this width * @param array $columns One or more columns with this width
* @throws WriterNotOpenedException * @throws WriterNotOpenedException
*/ */
public function setColumnWidth($width, ...$columns) { public function setColumnWidth($width, ...$columns)
{
$this->throwIfWorkbookIsNotAvailable(); $this->throwIfWorkbookIsNotAvailable();
$this->workbookManager->setColumnWidth($width, ...$columns); $this->workbookManager->setColumnWidth($width, ...$columns);
} }
@ -173,7 +174,8 @@ abstract class WriterMultiSheetsAbstract extends WriterAbstract
* @param int $end Last column index of the range * @param int $end Last column index of the range
* @throws WriterNotOpenedException * @throws WriterNotOpenedException
*/ */
public function setColumnWidthForRange(float $width, int $start, int $end) { public function setColumnWidthForRange(float $width, int $start, int $end)
{
$this->throwIfWorkbookIsNotAvailable(); $this->throwIfWorkbookIsNotAvailable();
$this->workbookManager->setColumnWidthForRange($width, $start, $end); $this->workbookManager->setColumnWidthForRange($width, $start, $end);
} }
@ -181,8 +183,8 @@ abstract class WriterMultiSheetsAbstract extends WriterAbstract
/** /**
* Checks if the workbook has been created. Throws an exception if not created yet. * Checks if the workbook has been created. Throws an exception if not created yet.
* *
* @throws WriterNotOpenedException If the workbook is not created yet
* @return void * @return void
* @throws WriterNotOpenedException If the workbook is not created yet
*/ */
protected function throwIfWorkbookIsNotAvailable() protected function throwIfWorkbookIsNotAvailable()
{ {

View File

@ -120,14 +120,16 @@ EOD;
/** /**
* @param float|null $width * @param float|null $width
*/ */
public function setDefaultColumnWidth($width) { public function setDefaultColumnWidth($width)
{
$this->defaultColumnWidth = $width; $this->defaultColumnWidth = $width;
} }
/** /**
* @param float|null $height * @param float|null $height
*/ */
public function setDefaultRowHeight($height) { public function setDefaultRowHeight($height)
{
$this->defaultRowHeight = $height; $this->defaultRowHeight = $height;
} }
@ -135,7 +137,8 @@ EOD;
* @param float $width * @param float $width
* @param array $columns One or more columns with this width * @param array $columns One or more columns with this width
*/ */
public function setColumnWidth(float $width, ...$columns) { public function setColumnWidth(float $width, ...$columns)
{
// Gather sequences // Gather sequences
$sequence = []; $sequence = [];
foreach ($columns as $i) { foreach ($columns as $i) {
@ -155,7 +158,8 @@ EOD;
* @param int $start First column index of the range * @param int $start First column index of the range
* @param int $end Last column index of the range * @param int $end Last column index of the range
*/ */
public function setColumnWidthForRange(float $width, int $start, int $end) { public function setColumnWidthForRange(float $width, int $start, int $end)
{
$this->columnWidths[] = [$start, $end, $width]; $this->columnWidths[] = [$start, $end, $width];
} }
@ -176,8 +180,8 @@ EOD;
* Checks if the sheet has been sucessfully created. Throws an exception if not. * 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 * @param bool|resource $sheetFilePointer Pointer to the sheet data file or FALSE if unable to open the file
* @throws IOException If the sheet data file cannot be opened for writing
* @return void * @return void
* @throws IOException If the sheet data file cannot be opened for writing
*/ */
private function throwIfSheetFilePointerIsNotAvailable($sheetFilePointer) private function throwIfSheetFilePointerIsNotAvailable($sheetFilePointer)
{ {
@ -203,9 +207,9 @@ 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 written * @param Row $row The row to be written
* @throws IOException If the data cannot be written
* @throws InvalidArgumentException If a cell value's type is not supported
* @return void * @return void
* @throws InvalidArgumentException If a cell value's type is not supported
* @throws IOException If the data cannot be written
*/ */
private function addNonEmptyRow(Worksheet $worksheet, Row $row) private function addNonEmptyRow(Worksheet $worksheet, Row $row)
{ {
@ -244,8 +248,8 @@ EOD;
* @param Style $rowStyle * @param Style $rowStyle
* @param int $rowIndex * @param int $rowIndex
* @param int $cellIndex * @param int $cellIndex
* @throws InvalidArgumentException If the given value cannot be processed
* @return string * @return string
* @throws InvalidArgumentException If the given value cannot be processed
*/ */
private function applyStyleAndGetCellXML(Cell $cell, Style $rowStyle, $rowIndex, $cellIndex) private function applyStyleAndGetCellXML(Cell $cell, Style $rowStyle, $rowIndex, $cellIndex)
{ {
@ -266,8 +270,8 @@ EOD;
* @param int $cellNumber * @param int $cellNumber
* @param Cell $cell * @param Cell $cell
* @param int $styleId * @param int $styleId
* @throws InvalidArgumentException If the given value cannot be processed
* @return string * @return string
* @throws InvalidArgumentException If the given value cannot be processed
*/ */
private function getCellXML($rowIndex, $cellNumber, Cell $cell, $styleId) private function getCellXML($rowIndex, $cellNumber, Cell $cell, $styleId)
{ {
@ -278,7 +282,7 @@ EOD;
if ($cell->isString()) { if ($cell->isString()) {
$cellXML .= $this->getCellXMLFragmentForNonEmptyString($cell->getValue()); $cellXML .= $this->getCellXMLFragmentForNonEmptyString($cell->getValue());
} elseif ($cell->isBoolean()) { } elseif ($cell->isBoolean()) {
$cellXML .= ' t="b"><v>' . (int) ($cell->getValue()) . '</v></c>'; $cellXML .= ' t="b"><v>' . (int)($cell->getValue()) . '</v></c>';
} elseif ($cell->isNumeric()) { } elseif ($cell->isNumeric()) {
$cellXML .= '><v>' . $cell->getValue() . '</v></c>'; $cellXML .= '><v>' . $cell->getValue() . '</v></c>';
} elseif ($cell->isEmpty()) { } elseif ($cell->isEmpty()) {
@ -300,8 +304,8 @@ EOD;
* Returns the XML fragment for a cell containing a non empty string * Returns the XML fragment for a cell containing a non empty string
* *
* @param string $cellValue The cell value * @param string $cellValue The cell value
* @throws InvalidArgumentException If the string exceeds the maximum number of characters allowed per cell
* @return string The XML fragment representing the cell * @return string The XML fragment representing the cell
* @throws InvalidArgumentException If the string exceeds the maximum number of characters allowed per cell
*/ */
private function getCellXMLFragmentForNonEmptyString($cellValue) private function getCellXMLFragmentForNonEmptyString($cellValue)
{ {
@ -331,7 +335,7 @@ EOD;
} }
$xml = '<cols>'; $xml = '<cols>';
foreach ($this->columnWidths as $entry) { foreach ($this->columnWidths as $entry) {
$xml .= '<col min="'.$entry[0].'" max="'.$entry[1].'" width="'.$entry[2].'" customWidth="true"/>'; $xml .= '<col min="' . $entry[0] . '" max="' . $entry[1] . '" width="' . $entry[2] . '" customWidth="true"/>';
} }
$xml .= '</cols>'; $xml .= '</cols>';
return $xml; return $xml;