ExamsGroupController::indexAction()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

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