Code Duplication    Length = 12-12 lines in 2 locations

src/PhpSpreadsheet/Worksheet.php 2 locations

@@ 855-866 (lines=12) @@
852
                    $pValue = Shared\StringHelper::substring($pValue, 0, 29);
853
                }
854
                $i = 1;
855
                while ($this->parent->sheetNameExists($pValue . ' ' . $i)) {
856
                    ++$i;
857
                    if ($i == 10) {
858
                        if (Shared\StringHelper::countCharacters($pValue) > 28) {
859
                            $pValue = Shared\StringHelper::substring($pValue, 0, 28);
860
                        }
861
                    } elseif ($i == 100) {
862
                        if (Shared\StringHelper::countCharacters($pValue) > 27) {
863
                            $pValue = Shared\StringHelper::substring($pValue, 0, 27);
864
                        }
865
                    }
866
                }
867
868
                $altTitle = $pValue . ' ' . $i;
869
@@ 2985-2996 (lines=12) @@
2982
                    $pValue = Shared\StringHelper::substring($pValue, 0, 29);
2983
                }
2984
                $i = 1;
2985
                while ($this->getParent()->sheetCodeNameExists($pValue . '_' . $i)) {
2986
                    ++$i;
2987
                    if ($i == 10) {
2988
                        if (Shared\StringHelper::countCharacters($pValue) > 28) {
2989
                            $pValue = Shared\StringHelper::substring($pValue, 0, 28);
2990
                        }
2991
                    } elseif ($i == 100) {
2992
                        if (Shared\StringHelper::countCharacters($pValue) > 27) {
2993
                            $pValue = Shared\StringHelper::substring($pValue, 0, 27);
2994
                        }
2995
                    }
2996
                }
2997
2998
                $pValue = $pValue . '_' . $i; // ok, we have a valid name
2999
                //codeName is'nt used in formula : no need to call for an update