New code review fixs

This commit is contained in:
Antoine Lamirault 2021-03-05 14:12:20 +01:00
parent 5c9c8f38b5
commit eea11b35e8
5 changed files with 10 additions and 21 deletions

View File

@ -490,13 +490,13 @@ class Style
return $this->isRegistered;
}
public function register(int $id) : void
public function markAsRegistered(?int $id) : void
{
$this->setId($id);
$this->isRegistered = true;
}
public function unregister() : void
public function unmarkAsRegistered() : void
{
$this->setId(0);
$this->isRegistered = false;

View File

@ -24,7 +24,7 @@ interface StyleManagerInterface
* Typically, set "wrap text" if a cell contains a new line.
*
* @param Cell $cell
* @return ManagedStyle|null The eventually updated style
* @return ManagedStyle The eventually updated style
*/
public function applyExtraStylesIfNeeded(Cell $cell) : ManagedStyle;
}

View File

@ -38,7 +38,7 @@ class StyleRegistry
if (!$this->hasSerializedStyleAlreadyBeenRegistered($serializedStyle)) {
$nextStyleId = \count($this->serializedStyleToStyleIdMappingTable);
$style->register($nextStyleId);
$style->markAsRegistered($nextStyleId);
$this->serializedStyleToStyleIdMappingTable[$serializedStyle] = $nextStyleId;
$this->styleIdToStyleMappingTable[$nextStyleId] = $style;
@ -47,19 +47,6 @@ class StyleRegistry
return $this->getStyleFromSerializedStyle($serializedStyle);
}
/**
* Returns whether the given style has already been registered.
*
* @param Style $style
* @return bool
*/
protected function hasStyleAlreadyBeenRegistered(Style $style)
{
$serializedStyle = $this->serialize($style);
return $this->hasSerializedStyleAlreadyBeenRegistered($serializedStyle);
}
/**
* Returns whether the serialized style has already been registered.
*
@ -114,11 +101,11 @@ class StyleRegistry
{
// In order to be able to properly compare style, set static ID value and reset registration
$currentId = $style->getId();
$style->unregister();
$style->unmarkAsRegistered();
$serializedStyle = \serialize($style);
$style->setId($currentId);
$style->markAsRegistered($currentId);
return $serializedStyle;
}

View File

@ -165,7 +165,8 @@ class WorksheetManager implements WorksheetManagerInterface
if ($managedStyle->isUpdated()) {
$registeredStyle = $this->styleManager->registerStyle($managedStyle->getStyle());
} else {
$registeredStyle = $rowStyle = $this->styleManager->registerStyle($rowStyle);
$registeredStyle = $this->styleManager->registerStyle($rowStyle);
$rowStyle = $registeredStyle;
}
} else {
$mergedCellAndRowStyle = $this->styleMerger->merge($cell->getStyle(), $rowStyle);

View File

@ -193,7 +193,8 @@ EOD;
if ($managedStyle->isUpdated()) {
$registeredStyle = $this->styleManager->registerStyle($managedStyle->getStyle());
} else {
$registeredStyle = $rowStyle = $this->styleManager->registerStyle($rowStyle);
$registeredStyle = $this->styleManager->registerStyle($rowStyle);
$rowStyle = $registeredStyle;
}
} else {
$mergedCellAndRowStyle = $this->styleMerger->merge($cell->getStyle(), $rowStyle);