Code Duplication    Length = 12-12 lines in 2 locations

src/PhpSpreadsheet/Worksheet.php 2 locations

@@ 868-879 (lines=12) @@
865
                    $pValue = Shared\StringHelper::substring($pValue, 0, 29);
866
                }
867
                $i = 1;
868
                while ($this->parent->sheetNameExists($pValue . ' ' . $i)) {
869
                    ++$i;
870
                    if ($i == 10) {
871
                        if (Shared\StringHelper::countCharacters($pValue) > 28) {
872
                            $pValue = Shared\StringHelper::substring($pValue, 0, 28);
873
                        }
874
                    } elseif ($i == 100) {
875
                        if (Shared\StringHelper::countCharacters($pValue) > 27) {
876
                            $pValue = Shared\StringHelper::substring($pValue, 0, 27);
877
                        }
878
                    }
879
                }
880
881
                $altTitle = $pValue . ' ' . $i;
882
@@ 3023-3034 (lines=12) @@
3020
                    $pValue = Shared\StringHelper::substring($pValue, 0, 29);
3021
                }
3022
                $i = 1;
3023
                while ($this->getParent()->sheetCodeNameExists($pValue . '_' . $i)) {
3024
                    ++$i;
3025
                    if ($i == 10) {
3026
                        if (Shared\StringHelper::countCharacters($pValue) > 28) {
3027
                            $pValue = Shared\StringHelper::substring($pValue, 0, 28);
3028
                        }
3029
                    } elseif ($i == 100) {
3030
                        if (Shared\StringHelper::countCharacters($pValue) > 27) {
3031
                            $pValue = Shared\StringHelper::substring($pValue, 0, 27);
3032
                        }
3033
                    }
3034
                }
3035
3036
                $pValue = $pValue . '_' . $i; // ok, we have a valid name
3037
                //codeName is'nt used in formula : no need to call for an update