Code Duplication    Length = 12-12 lines in 2 locations

src/PhpSpreadsheet/Worksheet.php 2 locations

@@ 841-852 (lines=12) @@
838
                    $pValue = Shared\StringHelper::substring($pValue, 0, 29);
839
                }
840
                $i = 1;
841
                while ($this->parent->sheetNameExists($pValue . ' ' . $i)) {
842
                    ++$i;
843
                    if ($i == 10) {
844
                        if (Shared\StringHelper::countCharacters($pValue) > 28) {
845
                            $pValue = Shared\StringHelper::substring($pValue, 0, 28);
846
                        }
847
                    } elseif ($i == 100) {
848
                        if (Shared\StringHelper::countCharacters($pValue) > 27) {
849
                            $pValue = Shared\StringHelper::substring($pValue, 0, 27);
850
                        }
851
                    }
852
                }
853
854
                $altTitle = $pValue . ' ' . $i;
855
@@ 2971-2982 (lines=12) @@
2968
                    $pValue = Shared\StringHelper::substring($pValue, 0, 29);
2969
                }
2970
                $i = 1;
2971
                while ($this->getParent()->sheetCodeNameExists($pValue . '_' . $i)) {
2972
                    ++$i;
2973
                    if ($i == 10) {
2974
                        if (Shared\StringHelper::countCharacters($pValue) > 28) {
2975
                            $pValue = Shared\StringHelper::substring($pValue, 0, 28);
2976
                        }
2977
                    } elseif ($i == 100) {
2978
                        if (Shared\StringHelper::countCharacters($pValue) > 27) {
2979
                            $pValue = Shared\StringHelper::substring($pValue, 0, 27);
2980
                        }
2981
                    }
2982
                }
2983
2984
                $pValue = $pValue . '_' . $i; // ok, we have a valid name
2985
                //codeName is'nt used in formula : no need to call for an update