сode formatting (CS Fixer)

This commit is contained in:
Alexander Rakushin 2019-07-10 20:52:27 +03:00 committed by Adrien Loison
parent 40aecd7b90
commit e8c6d83104
4 changed files with 6 additions and 14 deletions

View File

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

View File

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

View File

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