Completed
Push — master ( 35046b...d215ab )
by Mikołaj
03:13
created

ExamDelete   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 23
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A deleteAction() 0 9 1
A postDeleteAction() 0 10 2
1
<?php
2
3
namespace Egzaminer\Exam;
4
5
use Egzaminer\Admin\Dashboard as Controller;
6
7
class ExamDelete extends Controller
8
{
9
    public function deleteAction($id)
10
    {
11
        $exam = (new ExamModel($this->get('dbh')))->getInfo($id);
12
13
        $this->render('admin-delete', [
14
            'title'   => 'Usuwanie testu',
15
            'content' => 'Czy na pewno chcesz usunąć '.$exam['title'].'?',
16
        ]);
17
    }
18
19
    public function postDeleteAction($examID)
20
    {
21
        $delModel = new ExamDeleteModel($this->get('dbh'));
22
23
        if ($delModel->delete($examID)) {
24
            $this->redirectWithMessage('/admin', 'success', 'Usunięto pomyślnie!');
25
        } else {
26
            $this->redirectWithMessage('/admin/test/del/'.$examID, 'warning', 'Coś się zepsuło!');
27
        }
28
    }
29
}
30