Code Duplication    Length = 13-15 lines in 6 locations

src/controllers/TariffController.php 6 locations

@@ 74-87 (lines=14) @@
71
        ]);
72
    }
73
74
    public function actionCreateDomain($parent_id = null)
75
    {
76
        /** @var DomainTariffManager $manager */
77
        $manager = TariffManagerFactory::createByType('domain', $parent_id);
78
        $form = $manager->form;
79
80
        if (Yii::$app->request->isPost && $form->load(Yii::$app->request->post())) {
81
            $manager->insert();
82
83
            return $this->redirect(['view', 'id' => $form->id]);
84
        }
85
86
        return $this->render('domain/create', ['model' => $form]);
87
    }
88
89
    public function actionCreateSvds($parent_id = null)
90
    {
@@ 89-103 (lines=15) @@
86
        return $this->render('domain/create', ['model' => $form]);
87
    }
88
89
    public function actionCreateSvds($parent_id = null)
90
    {
91
        /** @var SvdsTariffManager $manager */
92
        $manager = TariffManagerFactory::createByType('svds', $parent_id);
93
94
        $form = $manager->form;
95
96
        if (Yii::$app->request->isPost && $form->load(Yii::$app->request->post())) {
97
            $manager->insert();
98
99
            return $this->redirect(['view', 'id' => $form->id]);
100
        }
101
102
        return $this->render('vds/create', ['model' => $form]);
103
    }
104
105
    public function actionCreateOvds($parent_id = null)
106
    {
@@ 105-118 (lines=14) @@
102
        return $this->render('vds/create', ['model' => $form]);
103
    }
104
105
    public function actionCreateOvds($parent_id = null)
106
    {
107
        /** @var OvdsTariffManager $manager */
108
        $manager = TariffManagerFactory::createByType('ovds', $parent_id);
109
        $form = $manager->form;
110
111
        if (Yii::$app->request->isPost && $form->load(Yii::$app->request->post())) {
112
            $manager->insert();
113
114
            return $this->redirect(['view', 'id' => $form->id]);
115
        }
116
117
        return $this->render('vds/create', ['model' => $form]);
118
    }
119
120
    public function actionCreateCertificate($parent_id = null)
121
    {
@@ 120-133 (lines=14) @@
117
        return $this->render('vds/create', ['model' => $form]);
118
    }
119
120
    public function actionCreateCertificate($parent_id = null)
121
    {
122
        /** @var CertificateTariffManager $manager */
123
        $manager = TariffManagerFactory::createByType('certificate', $parent_id);
124
        $form = $manager->form;
125
126
        if (Yii::$app->request->isPost && $form->load(Yii::$app->request->post())) {
127
            $manager->insert();
128
129
            return $this->redirect(['view', 'id' => $form->id]);
130
        }
131
132
        return $this->render('certificate/create', ['model' => $form]);
133
    }
134
135
    public function actionCreateServer($parent_id = null)
136
    {
@@ 135-148 (lines=14) @@
132
        return $this->render('certificate/create', ['model' => $form]);
133
    }
134
135
    public function actionCreateServer($parent_id = null)
136
    {
137
        /** @var ServerTariffManager $manager */
138
        $manager = TariffManagerFactory::createByType('server', $parent_id);
139
        $form = $manager->form;
140
141
        if (Yii::$app->request->isPost && $form->load(Yii::$app->request->post())) {
142
            $manager->insert();
143
144
            return $this->redirect(['view', 'id' => $form->id]);
145
        }
146
147
        return $this->render('server/create', ['model' => $form]);
148
    }
149
150
    public function actionUpdate($id)
151
    {
@@ 150-162 (lines=13) @@
147
        return $this->render('server/create', ['model' => $form]);
148
    }
149
150
    public function actionUpdate($id)
151
    {
152
        /** @var AbstractTariffManager $manager */
153
        $manager = TariffManagerFactory::createById($id, ['scenario' => 'update']);
154
        $form = $manager->form;
155
156
        if (Yii::$app->request->isPost && $form->load(Yii::$app->request->post())) {
157
            $manager->update();
158
159
            return $this->redirect(['view', 'id' => $form->id]);
160
        }
161
162
        return $this->render($manager->getType() . '/update', ['model' => $form]);
163
    }
164
165
    public function actionCopy()