Skip to content

Commit ea6ed77

Browse files
authored
refactor: cleanup code twice calling
1 parent 44c3bd5 commit ea6ed77

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/PhpSpreadsheet/Spreadsheet.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -660,9 +660,11 @@ public function getAllSheets(): array
660660
*/
661661
public function getSheetByName(string $worksheetName): ?Worksheet
662662
{
663-
$worksheetCount = count($this->workSheetCollection);
663+
$worksheetCount = count($this->workSheetCollection);
664+
$trimWorksheetName = trim($worksheetName, "'");
665+
664666
for ($i = 0; $i < $worksheetCount; ++$i) {
665-
if (strcasecmp($this->workSheetCollection[$i]->getTitle(), trim($worksheetName, "'")) === 0) {
667+
if (strcasecmp($this->workSheetCollection[$i]->getTitle(), $trimWorksheetName) === 0) {
666668
return $this->workSheetCollection[$i];
667669
}
668670
}

0 commit comments

Comments
 (0)