ExamModel   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A getInfo() 0 19 3
1
<?php
2
3
namespace Egzaminer\Model;
4
5
use PDO;
6
7
class ExamModel extends AbstractModel
8
{
9
    public function getInfo(int $examID): array
10
    {
11
        $stmt = $this->db->prepare('SELECT id, title, questions, threshold, group_id
12
            FROM exams WHERE id = :id');
13
        $stmt->bindValue(':id', $examID, PDO::PARAM_INT);
14
        $stmt->execute();
15
16
        $data = $stmt->fetch(PDO::FETCH_ASSOC);
17
18
        if ($data['questions'] > 0) {
19
            $data['thresholdPercentages'] = round($data['threshold'] / $data['questions'] * 100);
20
        }
21
22
        if (empty($data)) {
23
            $data = [];
24
        }
25
26
        return $data;
27
    }
28
}
29