Skip to content

Commit a70e4ec

Browse files
authored
Merge pull request #4499 from ddevsr/cleanup-twice
refactor: cleanup code twice calling
2 parents d41b304 + ca284fa commit a70e4ec

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/PhpSpreadsheet/Spreadsheet.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -691,10 +691,10 @@ public function getAllSheets(): array
691691
*/
692692
public function getSheetByName(string $worksheetName): ?Worksheet
693693
{
694-
$worksheetCount = count($this->workSheetCollection);
695-
for ($i = 0; $i < $worksheetCount; ++$i) {
696-
if (strcasecmp($this->workSheetCollection[$i]->getTitle(), trim($worksheetName, "'")) === 0) {
697-
return $this->workSheetCollection[$i];
694+
$trimWorksheetName = trim($worksheetName, "'");
695+
foreach ($this->workSheetCollection as $worksheet) {
696+
if (strcasecmp($worksheet->getTitle(), $trimWorksheetName) === 0) {
697+
return $worksheet;
698698
}
699699
}
700700

0 commit comments

Comments
 (0)