Code Duplication    Length = 12-12 lines in 2 locations

src/PhpSpreadsheet/Worksheet.php 2 locations

@@ 858-869 (lines=12) @@
855
                    $pValue = Shared\StringHelper::substring($pValue, 0, 29);
856
                }
857
                $i = 1;
858
                while ($this->parent->sheetNameExists($pValue . ' ' . $i)) {
859
                    ++$i;
860
                    if ($i == 10) {
861
                        if (Shared\StringHelper::countCharacters($pValue) > 28) {
862
                            $pValue = Shared\StringHelper::substring($pValue, 0, 28);
863
                        }
864
                    } elseif ($i == 100) {
865
                        if (Shared\StringHelper::countCharacters($pValue) > 27) {
866
                            $pValue = Shared\StringHelper::substring($pValue, 0, 27);
867
                        }
868
                    }
869
                }
870
871
                $altTitle = $pValue . ' ' . $i;
872
@@ 3008-3019 (lines=12) @@
3005
                    $pValue = Shared\StringHelper::substring($pValue, 0, 29);
3006
                }
3007
                $i = 1;
3008
                while ($this->getParent()->sheetCodeNameExists($pValue . '_' . $i)) {
3009
                    ++$i;
3010
                    if ($i == 10) {
3011
                        if (Shared\StringHelper::countCharacters($pValue) > 28) {
3012
                            $pValue = Shared\StringHelper::substring($pValue, 0, 28);
3013
                        }
3014
                    } elseif ($i == 100) {
3015
                        if (Shared\StringHelper::countCharacters($pValue) > 27) {
3016
                            $pValue = Shared\StringHelper::substring($pValue, 0, 27);
3017
                        }
3018
                    }
3019
                }
3020
3021
                $pValue = $pValue . '_' . $i; // ok, we have a valid name
3022
                //codeName is'nt used in formula : no need to call for an update