Code Duplication    Length = 12-12 lines in 2 locations

src/PhpSpreadsheet/Worksheet.php 2 locations

@@ 854-865 (lines=12) @@
851
                    $pValue = Shared\StringHelper::substring($pValue, 0, 29);
852
                }
853
                $i = 1;
854
                while ($this->parent->sheetNameExists($pValue . ' ' . $i)) {
855
                    ++$i;
856
                    if ($i == 10) {
857
                        if (Shared\StringHelper::countCharacters($pValue) > 28) {
858
                            $pValue = Shared\StringHelper::substring($pValue, 0, 28);
859
                        }
860
                    } elseif ($i == 100) {
861
                        if (Shared\StringHelper::countCharacters($pValue) > 27) {
862
                            $pValue = Shared\StringHelper::substring($pValue, 0, 27);
863
                        }
864
                    }
865
                }
866
867
                $altTitle = $pValue . ' ' . $i;
868
@@ 2902-2913 (lines=12) @@
2899
                    $pValue = Shared\StringHelper::substring($pValue, 0, 29);
2900
                }
2901
                $i = 1;
2902
                while ($this->getParent()->sheetCodeNameExists($pValue . '_' . $i)) {
2903
                    ++$i;
2904
                    if ($i == 10) {
2905
                        if (Shared\StringHelper::countCharacters($pValue) > 28) {
2906
                            $pValue = Shared\StringHelper::substring($pValue, 0, 28);
2907
                        }
2908
                    } elseif ($i == 100) {
2909
                        if (Shared\StringHelper::countCharacters($pValue) > 27) {
2910
                            $pValue = Shared\StringHelper::substring($pValue, 0, 27);
2911
                        }
2912
                    }
2913
                }
2914
2915
                $pValue = $pValue . '_' . $i; // ok, we have a valid name
2916
                //codeName is'nt used in formula : no need to call for an update