Code Duplication    Length = 12-12 lines in 2 locations

src/PhpSpreadsheet/Worksheet.php 2 locations

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