сode formatting (CS Fixer)
This commit is contained in:
parent
40aecd7b90
commit
e8c6d83104
@ -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()
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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'));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user