Code Duplication    Length = 12-12 lines in 2 locations

src/PhpSpreadsheet/Worksheet/Worksheet.php 2 locations

@@ 865-876 (lines=12) @@
862
                        $pValue = Shared\StringHelper::substring($pValue, 0, 29);
863
                    }
864
                    $i = 1;
865
                    while ($this->parent->sheetNameExists($pValue . ' ' . $i)) {
866
                        ++$i;
867
                        if ($i == 10) {
868
                            if (Shared\StringHelper::countCharacters($pValue) > 28) {
869
                                $pValue = Shared\StringHelper::substring($pValue, 0, 28);
870
                            }
871
                        } elseif ($i == 100) {
872
                            if (Shared\StringHelper::countCharacters($pValue) > 27) {
873
                                $pValue = Shared\StringHelper::substring($pValue, 0, 27);
874
                            }
875
                        }
876
                    }
877
878
                    $pValue .= " $i";
879
                }
@@ 3028-3039 (lines=12) @@
3025
                        $pValue = Shared\StringHelper::substring($pValue, 0, 29);
3026
                    }
3027
                    $i = 1;
3028
                    while ($this->getParent()->sheetCodeNameExists($pValue . '_' . $i)) {
3029
                        ++$i;
3030
                        if ($i == 10) {
3031
                            if (Shared\StringHelper::countCharacters($pValue) > 28) {
3032
                                $pValue = Shared\StringHelper::substring($pValue, 0, 28);
3033
                            }
3034
                        } elseif ($i == 100) {
3035
                            if (Shared\StringHelper::countCharacters($pValue) > 27) {
3036
                                $pValue = Shared\StringHelper::substring($pValue, 0, 27);
3037
                            }
3038
                        }
3039
                    }
3040
3041
                    $pValue = $pValue . '_' . $i; // ok, we have a valid name
3042
                }