Code Duplication    Length = 12-12 lines in 2 locations

src/PhpSpreadsheet/Worksheet.php 2 locations

@@ 843-854 (lines=12) @@
840
                    $pValue = Shared\StringHelper::substring($pValue, 0, 29);
841
                }
842
                $i = 1;
843
                while ($this->parent->sheetNameExists($pValue . ' ' . $i)) {
844
                    ++$i;
845
                    if ($i == 10) {
846
                        if (Shared\StringHelper::countCharacters($pValue) > 28) {
847
                            $pValue = Shared\StringHelper::substring($pValue, 0, 28);
848
                        }
849
                    } elseif ($i == 100) {
850
                        if (Shared\StringHelper::countCharacters($pValue) > 27) {
851
                            $pValue = Shared\StringHelper::substring($pValue, 0, 27);
852
                        }
853
                    }
854
                }
855
856
                $altTitle = $pValue . ' ' . $i;
857
                return $this->setTitle($altTitle, $updateFormulaCellReferences);
@@ 2930-2941 (lines=12) @@
2927
                    $pValue = Shared\StringHelper::substring($pValue, 0, 29);
2928
                }
2929
                $i = 1;
2930
                while ($this->getParent()->sheetCodeNameExists($pValue . '_' . $i)) {
2931
                    ++$i;
2932
                    if ($i == 10) {
2933
                        if (Shared\StringHelper::countCharacters($pValue) > 28) {
2934
                            $pValue = Shared\StringHelper::substring($pValue, 0, 28);
2935
                        }
2936
                    } elseif ($i == 100) {
2937
                        if (Shared\StringHelper::countCharacters($pValue) > 27) {
2938
                            $pValue = Shared\StringHelper::substring($pValue, 0, 27);
2939
                        }
2940
                    }
2941
                }
2942
2943
                $pValue = $pValue . '_' . $i;// ok, we have a valid name
2944
                //codeName is'nt used in formula : no need to call for an update