QuestionsModel   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
c 0
b 0
f 0
lcom 1
cbo 1
dl 0
loc 20
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getByExamId() 0 8 1
A getByQuestionId() 0 8 1
1
<?php
2
3
namespace Egzaminer\Model;
4
5
use PDO;
6
7
class QuestionsModel extends AbstractModel
8
{
9
    public function getByExamId(int $examID): array
10
    {
11
        $stmt = $this->db->prepare('SELECT * FROM questions WHERE exam_id = :exam_id');
12
        $stmt->bindValue(':exam_id', $examID, PDO::PARAM_INT);
13
        $stmt->execute();
14
15
        return $stmt->fetchAll(PDO::FETCH_ASSOC);
16
    }
17
18
    public function getByQuestionId(int $questionID): array
19
    {
20
        $stmt = $this->db->prepare('SELECT * FROM questions WHERE id = :id');
21
        $stmt->bindValue(':id', $questionID, PDO::PARAM_INT);
22
        $stmt->execute();
23
24
        return $stmt->fetch(PDO::FETCH_ASSOC);
25
    }
26
}
27