Completed
Push — master ( ac011d...56c397 )
by Mikołaj
03:19
created

ExamsGroupController::indexAction()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 14
rs 9.4285
cc 2
eloc 8
nc 2
nop 1
1
<?php
2
3
namespace Egzaminer\Controller;
4
5
use Exception;
6
use Egzaminer\Model\ExamsGroupModel;
7
use Egzaminer\Model\ExamsListModel;
8
9
class ExamsGroupController extends AbstractController
10
{
11
    /**
12
     * Exams group index action.
13
     *
14
     * GET /group/[i:id]
15
     *
16
     * @param int $examID Exam ID
17
     *
18
     * @return void
19
     */
20
    public function indexAction($examID)
21
    {
22
        $list = new ExamsListModel($this->get('dbh'));
23
        $examsList = $list->getExamsByGroupId($examID);
24
25
        $one = new ExamsGroupModel($this->get('dbh'));
26
        $info = $one->getExamsGroupInfoById($examID);
27
28
        if (empty($info)) {
29
            throw new Exception('Exams group does not exist!');
30
        }
31
32
        $this->render('front/list', ['title' => $info->title, 'examsList' => $examsList]);
33
    }
34
}
35