Code Duplication    Length = 13-13 lines in 2 locations

src/controllers/HubController.php 1 location

@@ 92-104 (lines=13) @@
89
        return $this->getFullFromRef('type,nic_media');
90
    }
91
92
    protected function getFullFromRef($gtype)
93
    {
94
        $callingMethod = debug_backtrace()[1]['function'];
95
        $result = Yii::$app->get('cache')->getOrSet([$callingMethod], function () use ($gtype) {
96
            $result = ArrayHelper::map(Ref::find()->where(['gtype' => $gtype, 'select' => 'full'])->all(), 'id', function ($model) {
97
                return Yii::t('hipanel:server:hub', $model->label);
98
            });
99
100
            return $result;
101
        }, 86400 * 24); // 24 days
102
103
        return $result;
104
    }
105
}

src/controllers/ServerController.php 1 location

@@ 649-661 (lines=13) @@
646
        return $result;
647
    }
648
649
    protected function getFullFromRef($gtype)
650
    {
651
        $callingMethod = debug_backtrace()[1]['function'];
652
        $result = Yii::$app->get('cache')->getOrSet([$callingMethod], function () use ($gtype) {
653
            $result = ArrayHelper::map(Ref::find()->where(['gtype' => $gtype, 'select' => 'full'])->all(), 'id', function ($model) {
654
                return Yii::t('hipanel:server:hub', $model->label);
655
            });
656
657
            return $result;
658
        }, 86400 * 24); // 24 days
659
660
        return $result;
661
    }
662
}
663