ExamAddController::addAction()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Egzaminer\Controller;
4
5
use Egzaminer\Model\ExamAddModel;
6
7
class ExamAddController extends AbstractController
8
{
9
    /**
10
     * Add exam.
11
     *
12
     * GET /admin/exam/add
13
     *
14
     * @return string
15
     */
16
    public function addAction(): string
17
    {
18
        return $this->render('admin/exam/add', [
19
            'title' => 'Dodawanie testu',
20
        ]);
21
    }
22
23
    /**
24
     * Add exam post action.
25
     *
26
     * POST /admin/exam/add
27
     *
28
     * @return void
29
     */
30 View Code Duplication
    public function postAddAction()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in 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...
31
    {
32
        $model = new ExamAddModel($this->get('dbh'));
33
34
        if ($examID = $model->add($this->getFromRequest('post'))) {
35
            $this->setMessage('success', 'Dodano pomyślnie');
36
            $this->redirect('/admin/exam/edit/'.$examID);
37
38
            return;
39
        }
40
41
        $this->setMessage('warning', 'Coś się zepsuło');
42
        $this->redirect('/admin/exam/add');
43
    }
44
}
45