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

@@ 594-606 (lines=13) @@
591
        return $result;
592
    }
593
594
    protected function getFullFromRef($gtype)
595
    {
596
        $callingMethod = debug_backtrace()[1]['function'];
597
        $result = Yii::$app->get('cache')->getOrSet([$callingMethod], function () use ($gtype) {
598
            $result = ArrayHelper::map(Ref::find()->where(['gtype' => $gtype, 'select' => 'full'])->all(), 'id', function ($model) {
599
                return Yii::t('hipanel:server:hub', $model->label);
600
            });
601
602
            return $result;
603
        }, 86400 * 24); // 24 days
604
605
        return $result;
606
    }
607
}
608