Code Duplication    Length = 12-12 lines in 2 locations

src/PhpSpreadsheet/Worksheet/Worksheet.php 2 locations

@@ 857-868 (lines=12) @@
854
                        $pValue = Shared\StringHelper::substring($pValue, 0, 29);
855
                    }
856
                    $i = 1;
857
                    while ($this->parent->sheetNameExists($pValue . ' ' . $i)) {
858
                        ++$i;
859
                        if ($i == 10) {
860
                            if (Shared\StringHelper::countCharacters($pValue) > 28) {
861
                                $pValue = Shared\StringHelper::substring($pValue, 0, 28);
862
                            }
863
                        } elseif ($i == 100) {
864
                            if (Shared\StringHelper::countCharacters($pValue) > 27) {
865
                                $pValue = Shared\StringHelper::substring($pValue, 0, 27);
866
                            }
867
                        }
868
                    }
869
870
                    $pValue .= " $i";
871
                }
@@ 3005-3016 (lines=12) @@
3002
                        $pValue = Shared\StringHelper::substring($pValue, 0, 29);
3003
                    }
3004
                    $i = 1;
3005
                    while ($this->getParent()->sheetCodeNameExists($pValue . '_' . $i)) {
3006
                        ++$i;
3007
                        if ($i == 10) {
3008
                            if (Shared\StringHelper::countCharacters($pValue) > 28) {
3009
                                $pValue = Shared\StringHelper::substring($pValue, 0, 28);
3010
                            }
3011
                        } elseif ($i == 100) {
3012
                            if (Shared\StringHelper::countCharacters($pValue) > 27) {
3013
                                $pValue = Shared\StringHelper::substring($pValue, 0, 27);
3014
                            }
3015
                        }
3016
                    }
3017
3018
                    $pValue = $pValue . '_' . $i; // ok, we have a valid name
3019
                }