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).
*
* @param Sheet $sheet The "external" sheet to set as current
* @throws SheetNotFoundException If the given sheet does not exist in the workbook
* @return void
* @throws SheetNotFoundException If the given sheet does not exist in the workbook
*/
public function setCurrentSheet(Sheet $sheet)
{
@ -291,14 +291,16 @@ abstract class WorkbookManagerAbstract implements WorkbookManagerInterface
/**
* @param float|null $width
*/
public function setDefaultColumnWidth(float $width) {
public function setDefaultColumnWidth(float $width)
{
$this->worksheetManager->setDefaultColumnWidth($width);
}
/**
* @param float|null $height
*/
public function setDefaultRowHeight(float $height) {
public function setDefaultRowHeight(float $height)
{
$this->worksheetManager->setDefaultRowHeight($height);
}
@ -306,7 +308,8 @@ abstract class WorkbookManagerAbstract implements WorkbookManagerInterface
* @param float $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);
}
@ -315,7 +318,8 @@ abstract class WorkbookManagerAbstract implements WorkbookManagerInterface
* @param int $start First 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);
}

View File

@ -50,8 +50,8 @@ abstract class WriterMultiSheetsAbstract extends WriterAbstract
* 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
* @throws WriterAlreadyOpenedException If the writer was already opened
* @return WriterMultiSheetsAbstract
* @throws WriterAlreadyOpenedException If the writer was already opened
*/
public function setShouldCreateNewSheetsAutomatically($shouldCreateNewSheetsAutomatically)
{
@ -76,8 +76,8 @@ abstract class WriterMultiSheetsAbstract extends WriterAbstract
/**
* Returns all the workbook's sheets
*
* @throws WriterNotOpenedException If the writer has not been opened yet
* @return Sheet[] All the workbook's sheets
* @throws WriterNotOpenedException If the writer has not been opened yet
*/
public function getSheets()
{
@ -112,8 +112,8 @@ abstract class WriterMultiSheetsAbstract extends WriterAbstract
/**
* Returns the current sheet
*
* @throws WriterNotOpenedException If the writer has not been opened yet
* @return Sheet The current sheet
* @throws WriterNotOpenedException If the writer has not been opened yet
*/
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).
*
* @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
* @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)
{
@ -162,7 +162,8 @@ abstract class WriterMultiSheetsAbstract extends WriterAbstract
* @param array $columns One or more columns with this width
* @throws WriterNotOpenedException
*/
public function setColumnWidth($width, ...$columns) {
public function setColumnWidth($width, ...$columns)
{
$this->throwIfWorkbookIsNotAvailable();
$this->workbookManager->setColumnWidth($width, ...$columns);
}
@ -173,7 +174,8 @@ abstract class WriterMultiSheetsAbstract extends WriterAbstract
* @param int $end Last column index of the range
* @throws WriterNotOpenedException
*/
public function setColumnWidthForRange(float $width, int $start, int $end) {
public function setColumnWidthForRange(float $width, int $start, int $end)
{
$this->throwIfWorkbookIsNotAvailable();
$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.
*
* @throws WriterNotOpenedException If the workbook is not created yet
* @return void
* @throws WriterNotOpenedException If the workbook is not created yet
*/
protected function throwIfWorkbookIsNotAvailable()
{

View File

@ -120,14 +120,16 @@ EOD;
/**
* @param float|null $width
*/
public function setDefaultColumnWidth($width) {
public function setDefaultColumnWidth($width)
{
$this->defaultColumnWidth = $width;
}
/**
* @param float|null $height
*/
public function setDefaultRowHeight($height) {
public function setDefaultRowHeight($height)
{
$this->defaultRowHeight = $height;
}
@ -135,7 +137,8 @@ EOD;
* @param float $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
$sequence = [];
foreach ($columns as $i) {
@ -155,7 +158,8 @@ EOD;
* @param int $start First 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];
}
@ -176,8 +180,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
* @throws IOException If the sheet data file cannot be opened for writing
* @return void
* @throws IOException If the sheet data file cannot be opened for writing
*/
private function throwIfSheetFilePointerIsNotAvailable($sheetFilePointer)
{
@ -203,9 +207,9 @@ EOD;
*
* @param Worksheet $worksheet The worksheet to add the row to
* @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
* @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)
{
@ -244,8 +248,8 @@ EOD;
* @param Style $rowStyle
* @param int $rowIndex
* @param int $cellIndex
* @throws InvalidArgumentException If the given value cannot be processed
* @return string
* @throws InvalidArgumentException If the given value cannot be processed
*/
private function applyStyleAndGetCellXML(Cell $cell, Style $rowStyle, $rowIndex, $cellIndex)
{
@ -266,8 +270,8 @@ EOD;
* @param int $cellNumber
* @param Cell $cell
* @param int $styleId
* @throws InvalidArgumentException If the given value cannot be processed
* @return string
* @throws InvalidArgumentException If the given value cannot be processed
*/
private function getCellXML($rowIndex, $cellNumber, Cell $cell, $styleId)
{
@ -278,7 +282,7 @@ EOD;
if ($cell->isString()) {
$cellXML .= $this->getCellXMLFragmentForNonEmptyString($cell->getValue());
} elseif ($cell->isBoolean()) {
$cellXML .= ' t="b"><v>' . (int) ($cell->getValue()) . '</v></c>';
$cellXML .= ' t="b"><v>' . (int)($cell->getValue()) . '</v></c>';
} elseif ($cell->isNumeric()) {
$cellXML .= '><v>' . $cell->getValue() . '</v></c>';
} elseif ($cell->isEmpty()) {
@ -300,8 +304,8 @@ EOD;
* Returns the XML fragment for a cell containing a non empty string
*
* @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
* @throws InvalidArgumentException If the string exceeds the maximum number of characters allowed per cell
*/
private function getCellXMLFragmentForNonEmptyString($cellValue)
{
@ -331,7 +335,7 @@ EOD;
}
$xml = '<cols>';
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>';
return $xml;