сode formatting (CS Fixer)

This commit is contained in:
Alexander Rakushin 2019-07-10 20:52:27 +03:00
parent b802cce694
commit 29bb8d322d
4 changed files with 6 additions and 14 deletions

View File

@ -72,7 +72,7 @@ class Style
private $hasSetBackgroundColor = false;
/** @var string Format */
private $format = null;
private $format;
/** @var bool */
private $hasSetFormat = false;
@ -412,7 +412,6 @@ class Style
}
/**
*
* @return bool Whether format should be applied
*/
public function shouldApplyFormat()

View File

@ -147,16 +147,18 @@ class StyleBuilder
return $this;
}
/**
* Sets a format
*
* @api
* @param string $format Format
* @return StyleBuilder
* @api
*/
public function setFormat($format)
{
$this->style->setFormat($format);
return $this;
}

View File

@ -15,7 +15,6 @@ class StyleRegistry extends \Box\Spout\Writer\Common\Manager\Style\StyleRegistry
* @var array Mapping between built-in format and the associated numFmtId
*/
protected static $builtinNumFormatToIdMapping = [
'General' => 0,
'0' => 1,
'0.00' => 2,
@ -65,7 +64,6 @@ class StyleRegistry extends \Box\Spout\Writer\Common\Manager\Style\StyleRegistry
't# ??/??' => 70,
];
/**
* @var array
*/
@ -123,7 +121,7 @@ class StyleRegistry extends \Box\Spout\Writer\Common\Manager\Style\StyleRegistry
{
$registeredStyle = parent::registerStyle($style);
$this->registerFill($registeredStyle);
$this->registerFormat($registeredStyle);;
$this->registerFormat($registeredStyle);
$this->registerBorder($registeredStyle);
return $registeredStyle;
@ -149,6 +147,7 @@ class StyleRegistry extends \Box\Spout\Writer\Common\Manager\Style\StyleRegistry
$this->styleIdToFormatsMappingTable[$styleId] = $registeredFormatId;
} else {
$this->registeredFormats[$format] = $styleId;
if (isset(self::$builtinNumFormatToIdMapping[$format])) {
$id = self::$builtinNumFormatToIdMapping[$format];
} else {
@ -156,7 +155,6 @@ class StyleRegistry extends \Box\Spout\Writer\Common\Manager\Style\StyleRegistry
}
$this->styleIdToFormatsMappingTable[$styleId] = $id;
}
} else {
// The formatId maps a style to a format declaration
// When there is no format definition - we default to 0 ( General )
@ -258,7 +256,6 @@ class StyleRegistry extends \Box\Spout\Writer\Common\Manager\Style\StyleRegistry
null;
}
/**
* @return array
*/
@ -275,7 +272,6 @@ class StyleRegistry extends \Box\Spout\Writer\Common\Manager\Style\StyleRegistry
return $this->registeredBorders;
}
/**
* @return array
*/
@ -283,5 +279,4 @@ class StyleRegistry extends \Box\Spout\Writer\Common\Manager\Style\StyleRegistry
{
return $this->registeredFormats;
}
}

View File

@ -225,7 +225,6 @@ class WriterWithStyleTest extends TestCase
->setFormat('0.000')
->build();
$dataRows = [
$this->createStyledRowFromValues([1.123456789], $style),
$this->createStyledRowFromValues([12.1], $style2),
@ -233,7 +232,6 @@ class WriterWithStyleTest extends TestCase
$this->writeToXLSXFile($dataRows, $fileName);
$formatsDomElement = $this->getXmlSectionFromStylesXmlFile($fileName, 'numFmts');
$this->assertEquals(
1,
@ -241,13 +239,11 @@ class WriterWithStyleTest extends TestCase
'There should be 2 formats, including the 1 default ones'
);
$cellXfsDomElement = $this->getXmlSectionFromStylesXmlFile($fileName, 'cellXfs');
foreach ([2, 164] as $index => $expected) {
$xfElement = $cellXfsDomElement->getElementsByTagName('xf')->item($index + 1);
$this->assertEquals($expected, $xfElement->getAttribute('numFmtId'));
}
}