TypeEditController::edit()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 23

Duplication

Lines 14
Ratio 60.87 %

Importance

Changes 0
Metric Value
cc 3
nc 3
nop 1
dl 14
loc 23
rs 9.552
c 0
b 0
f 0
1
<?php
2
3
namespace Rudolf\Modules\Appearance\Menu\Type;
4
5
use Rudolf\Component\Alerts\Alert;
6
use Rudolf\Component\Alerts\AlertsCollection;
7
use Rudolf\Framework\Controller\AdminController;
8
9
class TypeEditController extends AdminController
10
{
11
    /**
12
     * @param $id
13
     *
14
     * @throws \Exception
15
     */
16
    public function edit($id)
17
    {
18
        $model = new TypeEditModel();
19
        $view = new TypeEditView();
20
21 View Code Duplication
        if (isset($_POST['update'])) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
22
            if ($model->edit($id, $_POST)) {
23
                AlertsCollection::add(new Alert(
24
                    'success',
25
                    'Zaktualizowano!'
26
                ));
27
                $this->redirectTo(DIR.'/admin/appearance/menu/edit-type/'.$id);
28
                return;
29
            }
30
            AlertsCollection::add(new Alert(
31
                'error',
32
                'Coś się zepsuło!'
33
            ));
34
        }
35
36
        $view->display($model->getMenuTypeById($id));
37
        $view->render();
38
    }
39
}
40