Code Duplication    Length = 26-26 lines in 2 locations

src/Admin/CoreAdmin.php 2 locations

@@ 333-358 (lines=26) @@
330
     * @param type $tabName    the name of the tab to be renamed
331
     * @param type $newTabName the new name for the tab
332
     */
333
    public function renameFormTab($tabName, $newTabName, $keepOrder = true)
334
    {
335
        $tabs = $this->getFormTabs();
336
337
        if (!$tabs) {
338
            return;
339
        }
340
341
        if (!isset($tabs[$tabName])) {
342
            throw new \Exception(sprintf('Tab %s does not exist.', $tabName));
343
        }
344
        if (isset($tabs[$newTabName])) {
345
            return;
346
        }
347
348
        if ($keepOrder) {
349
            $keys = array_keys($tabs);
350
            $keys[array_search($tabName, $keys)] = $newTabName;
351
            $tabs = array_combine($keys, $tabs);
352
        } else {
353
            $tabs[$newTabName] = $tabs[$tabName];
354
            unset($tabs[$tabName]);
355
        }
356
357
        $this->setFormTabs($tabs);
358
    }
359
360
    /**
361
     * Rename a show tab after show fields have been configured.
@@ 368-393 (lines=26) @@
365
     * @param type $tabName    the name of the tab to be renamed
366
     * @param type $newTabName the new name for the tab
367
     */
368
    public function renameShowTab($tabName, $newTabName, $keepOrder = true)
369
    {
370
        $tabs = $this->getShowTabs();
371
372
        if (!$tabs) {
373
            return;
374
        }
375
376
        if (!isset($tabs[$tabName])) {
377
            throw new \Exception(sprintf('Tab %s does not exist.', $tabName));
378
        }
379
        if (isset($tabs[$newTabName])) {
380
            return;
381
        }
382
383
        if ($keepOrder) {
384
            $keys = array_keys($tabs);
385
            $keys[array_search($tabName, $keys)] = $newTabName;
386
            $tabs = array_combine($keys, $tabs);
387
        } else {
388
            $tabs[$newTabName] = $tabs[$tabName];
389
            unset($tabs[$tabName]);
390
        }
391
392
        $this->setShowTabs($tabs);
393
    }
394
395
    /**
396
     * Rename a form group.